开发者

XUL: Scroll to top and reload the page

recently I've installed the FireGestures plugin for Firefox, which I find very useful. You can also create your own scripts using JavaScript.

I want to create a script that simply scrolls to the top and then reloads the page. Sound simple, but I couldnt figure it out.

In FireGestures' help page it says "Of course, you can use global objects defined in browser.xul such as gBrowser, Cc and Ci."

I dont have eny experience with those and the Mozilla XUL documentation is one of the worst things that I've ever seen.

I've managed to trigger the reloading part by intuitively typing gBrowser.reload(); which reloads the current tab (exactly what i want).

开发者_C百科

How can I tell FireGestures to scroll to the top?


This worked for me.

goDoCommand('cmd_scrollTop');
gBrowser.reload();

This link has some more cmd_* commands with explanations (Just have to find the command among the Keyconfig syntax). http://kb.mozillazine.org/Keyconfig_extension:_Firefox

Also, viewing the source of some of the other Mappings will give you these cmd_* commands as well.

EDIT:

Here is a list of some of the more basic commands I found on the URL above (I haven't tested all of these):

  • Open Location: gBrowser.loadURI('http://www.mozilla.org/');
  • Next Tab: gBrowser.mTabContainer.advanceSelectedTab(1);
  • Previous Tab: gBrowser.mTabContainer.advanceSelectedTab(-1);
  • Reload All Tabs: gBrowser.reloadAllTabs();
  • Close current Tab: var tab = gBrowser.mCurrentTab; gBrowser.removeTab(tab);
  • Scroll Page Down: goDoCommand('cmd_scrollPageDown');
  • Scroll Page Up: goDoCommand('cmd_scrollPageUp');
  • Scroll to the Bottom: goDoCommand('cmd_scrollBottom');
  • Scroll to the Top: goDoCommand('cmd_scrollTop');
  • Scroll Line Down: goDoCommand('cmd_scrollLineDown');
  • Scroll Line Up: goDoCommand('cmd_scrollLineUp');

EDIT:

Here is a more comprehensive list of commands (Also untested):
https://developer.mozilla.org/en/XUL/List_of_commands

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜