开发者

Disabling a toolbarbutton when there is no page to go back - Firefox extension

开发者 https://www.devze.com 2023-04-09 09:43 出处:网络
I need to disable a toolbar button when there is no page to go back in history object. Similar to the browser back 开发者_开发技巧button.

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.

0

精彩评论

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