javascript - 历史记录 Goback 不起作用

标签 javascript

我在页面中有产品列表。这个产品列表只会显示 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/

相关文章:

javascript - 在为系统编写 Web 后端时,代码在没有 Javascript 的情况下仍然可以工作是否重要?

javascript - 当页面保存在 DOM 中时,如何使用开/关在 Jquery-Mobile 中正确解除绑定(bind)事件?

javascript - 在不破坏表单内容的情况下添加到 innerHTML

javascript - Angular2 - OnInit 访问函数

javascript - 使用 *ngFor 迭代 Promise<any[]>?

使用 AJAX 检索表单时,Javascript 表单提交 PreventDefault 不起作用

javascript - 我想在输入框、表格或使用node.js的div中的.html文件中显示存储在mysql数据库中的数据

javascript - 如何在 Promise.all 中正确地链式 Promise?

php - 前往 PHP 中的另一个页面

javascript - E>F 和 E+F 选择器的区别?