开发者

Running a JS method once to initiate variable when the chrome extension is loaded once?

开发者 https://www.devze.com 2023-04-11 13:19 出处:网络
I开发者_如何学编程 need to load a var by getting JSON from a webservice, so my question is where does this code go? I tried to put it in the content script but XHR would fail there.

I开发者_如何学编程 need to load a var by getting JSON from a webservice, so my question is where does this code go? I tried to put it in the content script but XHR would fail there. Any suggestions?


Starting from Chrome 13 content scripts can also perform XHR requests (before only background pages could). So you can put your code wherever you like.

If it doesn't work then you probably didn't specify domain permissions (or trying to connect to non-80 port, to non-http(s) protocol etc).

0

精彩评论

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

关注公众号