我的firefox扩展有一个对象myExt.
myExt = {
request: function(){
//adds dynamic script element to the current webpage's head tag
},
callback: function(json) {
//do something with this
}
};
Run Code Online (Sandbox Code Playgroud)
myExt.request将一个动态添加的脚本元素添加到返回json的服务器,我希望将json发送到我的扩展的js代码中存在的myExt.callback.
从我的扩展
//from my extension, i add a script element
myExt.request();
Run Code Online (Sandbox Code Playgroud)
ping服务器,返回网页
//from server i get the following response
myExt.callback ( {"some":"json"}) ;
//but the window doesnt find a reference to myExt
Run Code Online (Sandbox Code Playgroud)
如何从网页中引用myExt变量?