[Project_owners] urlBar Listener

joe ertaba belaviyo at gmail.com
Thu Jul 5 01:10:52 PDT 2007


hi gays

i need to show some local file instead original url when user dont set font
size of current page.
so i need to change tab url by:


var myExt_urlBarListener = {
QueryInterface: function(aIID)
{
if (aIID.equals(Components.interfaces.nsIWebProgressListener) ||
aIID.equals(Components.interfaces.nsISupportsWeakReference) ||
aIID.equals(Components.interfaces.nsISupports))
return this;
throw Components.results.NS_NOINTERFACE;
},

onLocationChange: function(aProgress, aRequest, aURI)
{
myExtension.processNewURL(aURI);
},

onStateChange: function() {},
onProgressChange: function() {},
onStatusChange: function() {},
onSecurityChange: function() {},
onLinkIconAvailable: function() {}
};

var myExtension = {
oldURL: null,

init: function() {
// Listen for webpage loads
gBrowser.addProgressListener(myExt_urlBarListener,
Components.interfaces.nsIWebProgress.NOTIFY_STATE_DOCUMENT);
},

uninit: function() {
gBrowser.removeProgressListener(myExt_urlBarListener);
},

processNewURL: function(aURI) {
if (aURI.spec == this.oldURL)
return;

// now we know the url is new...
alert(aURI.spec);
this.oldURL = aURI.spec;
}
};

window.addEventListener("load", function() {myExtension.init()}, false);

window.addEventListener("unload", function() {myExtension.uninit()}, false);



any body can help me?
is it possible to change tab url directly or i must find tab index first and
then change it ?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mozdev.org/pipermail/project_owners/attachments/20070705/7c382a70/attachment.html 


More information about the Project_owners mailing list