Reading an extension file through Jquery
I am trying to read Google chrome extension static html file in my content script and load it into div as follows:
$(menuDiv).load(chrome.extension.getURL("popup.html"));
However, I a开发者_JS百科m getting the error
XMLHttpRequest cannot load chrome-extension://kefhgglpbeopmaaljlplohlfgkdekgmc/popup.html. Cross origin requests are only supported for HTTP.
Any idea how to solve this ?
Content scripts are not allowed to make cross-site XMLHttpRequests: http://code.google.com/chrome/extensions/content_scripts.html
As a workaround, have your content script send a request to your background page, let the background page fetch popup.html's contents, and then pass a message back to your content script with the contents.
http://code.google.com/chrome/extensions/messaging.html
精彩评论