向后移动历史记录,使用不同的查询字符串跳过同一页面 [英] Move backward through history skipping the same page with different query string
问题描述
当我刷新页面或使用相同的网址重定向到同一页面时,我可以点击一个带有window.history.back();的按钮。代码并返回上一页。
When I refresh a page or redirect to the same one using the same url, I can click in a button with "window.history.back();" code and go back to the previous page.
但是,如果查询字符串已更改,我只是在我尝试移回时返回同一页面。
However, If the query string was changed, I just back to the same page when I try to move back.
示例1:
page1.html - > page2.html - > page2.html
- > [点击后退按钮] - > page1.html
示例2:
page1.html - > page2.html - >
page2.html?x = 123 - > [点击返回
按钮] - > page2.html
我想要的是什么:
page1.html - > page2.html - >
page2.html?x = 123 - > [点击返回
按钮] - > page1.html
所以问题是,我可以使用JavaScript忽略页面是否相同查询字符串更改并返回到真实的上一页?
So, the question is, Can I check if the page is the same using JavaScript to ignore query string changes and move back to the real previous page?
推荐答案
使用
<a href="page2.html?x=123"
onclick="location.replace(this.href); return false">Next</a>
继续前进
这篇关于向后移动历史记录,使用不同的查询字符串跳过同一页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!