Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

Opening window/tab helper library for Mozilla (See related posts)

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

You need to create an account or log in to post comments to this site.


Related Posts