Created
April 18, 2010 11:56
-
-
Save pwlin/370188 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Opening window/tab helper library for Mozilla | |
var $window = { | |
open_in_new_tab: function(url){ | |
getBrowser().selectedTab = getBrowser().addTab(url); | |
}, | |
open_in_same_tab: function(url){ | |
top.content.document.location = url; | |
}, | |
open_as_popup: function(url){ | |
var mypopup = window.open(url,'popuppage','toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=700,height=400,left=30,top=30'); | |
mypopup.focus(); | |
}, | |
focus: function(obj){ | |
obj.focus(); | |
}, | |
click : function(aEvent,url){ | |
if (aEvent.button == 2){ | |
this.open_as_popup(url); | |
} | |
else if ((aEvent.ctrlKey) || (aEvent.button == 1) || (aEvent.metaKey)){ | |
this.open_in_new_tab(url); | |
} | |
else { | |
this.open_in_same_tab(url); | |
this.focus(window._content); | |
} | |
} | |
} | |
Usage: | |
<toolbarbutton id="myid" label="my button" class="toolbarbutton-1" onclick="$window.click(event,'http://localhost/');" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment