我在页面中有产品列表。这个产品列表只会显示 5 个。单击“显示额外”按钮后,它将显示剩余的产品。
好的,在我点击“显示额外”按钮后,它会显示接下来的 5 个产品。现在共有 8 个产品。在剩下的 5 个产品中,当我单击任何一个产品链接 (href) 时,它会转到下一页。问题是,从下一页开始,当我单击“返回”按钮时,它会返回到该页面,但是此时,产品数量仍然是 5,而不是 10。但是我需要以前加载的产品,因为它就是这样。如果我简单地说,历史回溯不起作用。
请推荐我。
最佳答案
试试这个
javascript: history.go(-1)
<input type="button" value="Back" onClick="history.go(-1)">
history.back() and history.go(-1) are completely identical methods. Of course history.go() can take other parms including URL's or Page Titles while history.back() can only do one thing.
history.previous is a property and returns the URL of the previous item in the history object.
var lastURL = history.previous
However, this is a security issue and requires a signed script with explicit permission from the visitor to successfully use history.previous, .current, .next. Unlike the history.back() and history.go() methods, this one is not settable. It's only gettable.
重新加载页面后,数据当然会丢失:) ...您可以使用浏览器存储来保存加载的数据数量并在重新加载后再次加载相同的数据... w3schools.com/html/html5_webstorage .asp 享受:)
关于javascript - 历史记录 Goback 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23653118/