How to call a function from injected script?

Viewed 4192

This is code from my contentScript.js:

function loadScript(script_url)
  {
      var head= document.getElementsByTagName('head')[0];
      var script= document.createElement('script');
      script.type= 'text/javascript';
      script.src= chrome.extension.getURL('mySuperScript.js');
      head.appendChild(script);
      someFunctionFromMySuperScript(request.widgetFrame);// ReferenceError: someFunctionFromMySuperScript is not defined
  }

but i got an error when calling a function from injected script:

ReferenceError: someFunctionFromMySuperScript is not defined

Is there is a way to call this function without modifying mySuperScript.js?

3 Answers
Related