I need to disable a toolbar button when there is no page to go back in history object. Similar to the browser back 开发者_开发技巧button.
How can I do this?
You use tabbrowser.sessionHistory
property:
gBrowser.sessionHistory.addSHistoryListener(myListener);
Your listener should check whether gBrowser.sessionHistory.index
is 0 (nothing to go back) and set button.disabled
property appropriately.
Either that or you simply make your button observe the browser's back button using <observes>
tag:
<toolbarbutton ...>
<observes element="Browser:Back" attribute="disabled"/>
</toolbarbutton>
This makes sure that the disabled
attribute for your button is copied over from the Browser:Back
command.
精彩评论