(编辑:更改了大部分问题)
我得到了关于的答案如何转到标签的第一页。
基本上是一个书签小工具
javascript:window.history.go(-(window.history.length - 1))
它在所有页面上都能很好地运行,但在某些页面上,特别是那些长时间闲置的页面,它却不能。
有没有更好的方法来使用该书签小程序?
答案1
我会尝试在您传递的值上添加某种形式的验证。另外:您说它不起作用,但没有说明它是如何不起作用的(例如“它刷新当前页面”;或“它返回到第 1 页加 1”)
摘自 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.