Take the 2-minute tour ×

(edit: changed most of the question)

I got my answer regarding How to go to the very first page of a tab.

Basically a bookmarklet

  javascript:window.history.go(-(window.history.length - 1))

It works well from all pages, but from some pages, especially the ones that were idle for a long time, it doesn't.

Is there a better way to use that bookmarklet?

share|improve this question
I'm not using either, but: what does javascript:alert(window.history.length) give you? (Just copy & paste into the location/address bar, of the window that has iGoogle loaded.) –  Arjan Dec 1 '10 at 16:47
It gives me the correct number (was 19 for Google news, which does a refresh via href=... [see above]). Tried to check window.onunload and body.onunload they're all undefined. –  ring0 Dec 1 '10 at 16:49
Maybe lower the number a bit, like javascript:window.history.go(-5) to see what happens? –  Arjan Dec 1 '10 at 16:51
And: any errors when you open the Javascript console? (Just type javascript: to open that -- though that fails on my FF4 beta now.) –  Arjan Dec 1 '10 at 16:54
No error in Firebug. This is really strange... –  ring0 Dec 20 '10 at 23:18
show 1 more comment

1 Answer

I would try adding some form of validation on the value you are passing. Also: you say it doesn't work but you don't say how it doesn't work (e.g. "it refreshes the current page"; or "it goes back to 1st page plus 1")

Cribbed from w3:

The go(delta) method causes the UA to run the following steps:

   1. If the argument to the method was omitted or has the value zero, then act as if the location.reload() method was called instead, and abort these steps.
   2. Let delta be the argument to the method.
   3. If the index of the current entry of the joint session history plus delta is less than zero or greater than or equal to the number of items in the joint session history, then the user agent must do nothing.
   4. Let specified entry be the entry in the joint session history whose index is the sum of delta and the index of the current entry of the joint session history.
   5. Let specified browsing context be the browsing context of the specified entry.
   6. Traverse the history of the specified browsing context to the specified entry.
share|improve this answer
"It doesn't work" means that the browser tab doesn't move at all. The bookmarklet has not effect. Changing the go(x) with x==-1 doesn't have any effect either - while the history.length is 10. Maybe a Firefox pb... –  ring0 Dec 30 '10 at 16:56
add comment

Your Answer


