location.href="javascript:Function(); isn't working for Firefox extensions

半腔热情 提交于 2019-12-24 09:37:31

问题


In Chrome web-browser extensions I can use the next method for calling/triggering a web-site's (page) js function:

location.href="javascript:SomeFunction(); void 0";

It works great.

But it doesn't work for Firefox

Though in old Firefox addons I could call web-site's js functions in similar way like this:

var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
                  .getService(Components.interfaces.nsIWindowMediator);
var mainWindow = wm.getMostRecentWindow("navigator:browser");
mainWindow.gBrowser.loadURI("javascript:SomeFunction(); void 0");

But now it's all about Firefox Web Extensions and I wanted location.href="javascript:SomeFunction(); void 0"; to be working in FF

来源:https://stackoverflow.com/questions/42577963/location-href-javascriptfunction-isnt-working-for-firefox-extensions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!