Hi Need some help...
In order to automatically open a URL from Locationbar in New Tab, we have the following code:
Code: Select all
eval("gURLBar.handleCommand = " + gURLBar.handleCommand.toString().replace("if (aTriggeringEvent instanceof MouseEvent)", "if ((gBrowser.currentURI.spec != 'about:blank' || gBrowser.webProgress.isLoadingDocument) && (!aTriggeringEvent || !aTriggeringEvent.ctrlKey && !aTriggeringEvent.shiftKey && !aTriggeringEvent.altKey)) gBrowser.selectedTab = gBrowser.addTab(); $&"));
Now, in Fx3.1/3.5, besides wanting to overwrite an 'about:blank' tab (which is taken care of in this code), there are a couple of other scenarios where one would want to overwrite an existing tab instead of opening a new one:
- When you switch to Private Browsing mode, Fx displayed the about:privatebrowsing page. When a new URL is entered, it reads this as a loaded page and opens the URL in a new tab. Ideally this page should be overwritten.
- If you have installed this extension
http://labs.mozilla.com/2009/03/firefox-new-tab-next-iteration/ , and open a new tab (Ctrl+T), it displays the new 'New Tab' page. Now again, when I input a URL and click enter, it opens in a new tab, though I would ideally want to overwrite this tab.
In order to implement these changes, I modified the code a bit. Now, I don't really know Javascript, and I get a feeling that the following script is not optimal - it works though. Was looking to see if someone can help in optimising this a bit, if possible at all.
Code: Select all
eval("gURLBar.handleCommand = " + gURLBar.handleCommand.toString().replace("if (aTriggeringEvent instanceof MouseEvent)", "if ((gBrowser.currentURI.spec != 'about:blank' || gBrowser.webProgress.isLoadingDocument) && (gBrowser.currentURI.spec != 'about:privatebrowsing') && (gBrowser.currentURI.spec != 'chrome://abouttab/content/text.html') && (!aTriggeringEvent || !aTriggeringEvent.ctrlKey && !aTriggeringEvent.shiftKey && !aTriggeringEvent.altKey)) gBrowser.selectedTab = gBrowser.addTab(); $&"));
Another note:
The default page that shows up with the 'New Tab' extension is chrome://abouttab/content/text.html, but it also has a sibling chrome://abouttab/content/tab.html. Instead of mentioning them separately, can't I just say chrome://abouttab/* and get the same behavior?
Any help is appreciated. Thanks.