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
location.href="javascript:SomeFunction(); void 0";
so could call the function whenever I want, not just on load dom/page – Elma<script>
element containing the code which you desire to run. You are effectively adding<script>SomeFunction();</script>
to the DOM. While somewhat more complicated than what you stated, it can be used in the same way. It executes when you add it to the DOM, not upon DOM load/page load. – Ambulancelocation.href="javascript:...; void 0";
isn't working in FF – Elma