firefox - Notification when the value in Address Bar changes -


how notified whenever url in address bar (also known location bar) changes. using following code, tried notified when user navigates page (by clicking link, using back/forward button, typing address in location bar, etc.) , when user switches tabs.

var myextension = { oldurl: null,   init: function() {     gbrowser.addprogresslistener(this); },  uninit: function() {     gbrowser.removeprogresslistener(this); },  processnewurl: function(auri) {     if (auri.spec == this.oldurl) return;      // know url new...     alert(auri.spec);     this.oldurl = auri.spec; },  // nsiwebprogresslistener queryinterface: xpcomutils.generateqi(["nsiwebprogresslistener",                                        "nsisupportsweakreference"]),  onlocationchange: function(aprogress, arequest, auri) {     this.processnewurl(auri); },  onstatechange: function() {}, onprogresschange: function() {}, onstatuschange: function() {}, onsecuritychange: function() {} };   };   window.addeventlistener("load", function() { myextension.init() }, false); window.addeventlistener("unload", function() { myextension.uninit() }, false); 

but code getting reference error xpcomutils , window.i m developing code on firefox add-on builder. there need import???

add code @ beginning of file import xpcomutils.jsm

var {cc, ci, cu} = require("chrome"); cu.import("resource://gre/modules/xpcomutils.jsm", this); 

Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -