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/');" />