I've injected two .js files (Let' say for example a.js and b.js ) into a web page using content script, using technique mentioned here:
Access window variable from Content Script
function injectScript(file, node) {
var th = document.getElementsByTagName(node)[0];
var s = document.createElement('script');
s.setAttribute('type', 'text/javascript');
s.setAttribute('src', file);
th.appendChild(s);
}
injectScript( chrome.extension.getURL('/js/my_file.js'), 'body');
Both script injections are successful. Now 'a.js' has a function called FuncA(){}. Now when I'm trying to call FuncA() from b.js I'm getting following error.
b.js:6 Uncaught ReferenceError: FuncA is not defined