问题
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