When I try to include the jQuery library in my extension, the JS engine gives me an error. This is the code:
chrome.tabs.executeScript(null,{code:"
if (typeof jQuery == 'undefined') {
var script = document.createElement('script');
script.setAttribute('type') = 'text/javascript';
script.setAttribute('src') = 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js';
document.getElementsByTagName('head')[0].appendChild(script);
};
"});
and this the result:
Uncaught ReferenceError: Invalid left-hand side in assignment
(anonymous function)
This piece of code is written in the popup.js file, included by popup.html.
Even when i do something like this:
chrome.tabs.executeScript(null, {file: "browser.js", allFrames: true}, window.close());
and, in browser.js I specify the code written above (in which I include the jQuery library), it happens the same stuff. The strangest thing is that jQuery appears not to be defined at all, even when the tab in which the code is executed has already decleared it (such as Flickr, for example). In fact, typeof jQuery is always set to 'undefined'. I'm quite confused...