admin管理员组文章数量:1323730
my firefox extension has an object myExt .
myExt = {
request: function(){
//adds dynamic script element to the current webpage's head tag
},
callback: function(json) {
//do something with this
}
};
myExt.request adds a dynamically added script element to a server that returns json, i want the json to be sent to myExt.callback that exists within my extension's js code.
from my extension
//from my extension, i add a script element
myExt.request();
pings the server, back into the webpage
//from server i get the following response
myExt.callback ( {"some":"json"}) ;
//but the window doesnt find a reference to myExt
how do i make a reference to myExt variable from the webpage ?
my firefox extension has an object myExt .
myExt = {
request: function(){
//adds dynamic script element to the current webpage's head tag
},
callback: function(json) {
//do something with this
}
};
myExt.request adds a dynamically added script element to a server that returns json, i want the json to be sent to myExt.callback that exists within my extension's js code.
from my extension
//from my extension, i add a script element
myExt.request();
pings the server, back into the webpage
//from server i get the following response
myExt.callback ( {"some":"json"}) ;
//but the window doesnt find a reference to myExt
how do i make a reference to myExt variable from the webpage ?
Share Improve this question asked May 14, 2010 at 12:30 bosky101bosky101 2,3221 gold badge18 silver badges10 bronze badges2 Answers
Reset to default 5Firefox extensions run JavaScript with high privilege (chrome) and have full access to the browser. JavaScript code from a web page run unprivileged JavaScript and among other things cannot reference or interact directly with the privileged JavaScript.
In general, you have to be very careful when your extension code interacts with code ing from websites in order not to open a security hole that could allow a malicious website to execute JavaScript with chrome privileges.
You can find more information here, including code snippets if you need to exchange data between privileged and unprivileged JavaScript:
https://developer.mozilla/en/Security_best_practices_in_extensions
See also this link to exchange data between privileged and unprivileged JavaScript:
https://developer.mozilla/en/Code_snippets/Interaction_between_privileged_and_non-privileged_pages
本文标签: javascripthow to access a firefox extension variable from the current documentwindowStack Overflow
版权声明:本文标题:javascript - how to access a firefox extension variable from the current documentwindow - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742121836a2421746.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论