开发者

Reading an extension file through Jquery

开发者 https://www.devze.com 2023-03-19 12:33 出处:网络
I am trying to read Google chrome extension static html file in my content script and load it into div as follows:

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

0

精彩评论

暂无评论...
验证码 换一张
取 消