开发者

Toggle Toolbar in Firefox extension

开发者 https://www.devze.com 2023-02-15 16:11 出处:网络
I have a toolbarbutton and I want it to toggle a toolbox > toolbar when it is clicked. I thought there might be an internal function开发者_JAVA百科 similar to toggleSidebar(id) but I cannot find it.We

I have a toolbarbutton and I want it to toggle a toolbox > toolbar when it is clicked. I thought there might be an internal function开发者_JAVA百科 similar to toggleSidebar(id) but I cannot find it.


Well there is no function, however there is a simple solution for anyone looking for it.

First on the toolbarbutton add the following attribute:

oncommand="extName.toggleToolbar(event);"

then in the javascript:

toggleToolbar: function(e) {
    var toolbar = document.getElementById('uniqueName-toolbar');

    if(toolbar.getAttribute('hidden')== 'true'){
        toolbar.setAttribute('hidden', false);
    }
    else{
        toolbar.setAttribute('hidden', true);
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号