我正在使用XUL开发Mozilla Extension(Legacy扩展)。在此
window
.addEventListener(
"load",
function(event) {
(function(loader) {
loader
.loadSubScript("chrome://cashbackurl/content/jquery-1.11.3.min.js");
})
(Components.classes["@mozilla.org/moz/jssubscript-loader;1"]
.getService(Components.interfaces.mozIJSSubScriptLoader));
// Your code goes
myExtension.init();
}, false);
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) {
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);
if (win.top == win.self) {
cburl.getDataLoder();
}
}
}
我在这里使用" doc"获取当前网址的引荐来源的元素。我尝试使用doc.referrer,但我没有得到正确的推荐人。任何曾经建议我如何解决这个问题。
谢谢。