I am building a Firefox add-on. I have attached an event listener to links with a class. On link click I need to redirect the user to a different page (preferably separate tab) with some additional parameters added to it as query string. How can I achieve this from the addon? I tried setting location.href
but it opens the target like a popup (I mean a window without any toolbar and menubar).
This is the function that gets triggered on lck event:
var myExtension = {
init: function() {
// The event can be DOMContentLoaded, pageshow, pagehide, load or unload.
if(gBrowser) gBrowser.addEventListener("DOMContentLoaded", this.onPageLoad, false);
},
onPageLoad: function(aEvent) {
var doc = aEvent.originalTarget; // doc is document that triggered the event
var win = doc.defaultView; // win is the window for the doc
// test desired conditions and do something
// if (doc.nodeName == "#document") return; // only documents
// if (win != win.top) return; //only top window.
// if (win.frameElement) return; // skip iframes/frames
// alert("page is loaded \n" +doc.location.href);
function toFb()
{
var Ele2=doc.getElementsByClassName('js-action-reply')[0].parentNode.parentNode.parentNode.parentNode.children[1];
doc.location.href="http://www.lendingstream.co.uk/?txt="+Ele2.innerHTML;
}
}
}
window.addEventListener("load", function load(event){
window.removeEventListener("load", load, false); //remove listener, no longer needed
myExtension.init();
},false);