在Javascript中,我如何“清除”后面(历史-1)? [英] In Javascript, how do I "clear" the back (history -1)?

查看:163
本文介绍了在Javascript中,我如何“清除”后面(历史-1)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户加载页面时,我立即将窗口重定向到另一个位置。



问题是,当用户点击回来时,



我可以取消上一页的历史记录吗?这样当用户点击背部,它可以追溯到两页呢?


解决方案

而不是使用窗口.location = url; 以重定向,



请尝试:

  window.location.replace(url); 




使用替代()当前页面后不会被保存在会议
历史,意味着用户将无法使用返回按钮来
导航到它。



When the user loads the page, I immediately do a window redirect to another location.

The problem is, when the user clicks back, it'll go back to the page which does the redirect.

Can I "cancel" the history of the previous page? So that when the user clicks back, it goes back TWO pages instead?

解决方案

Instead of using window.location = url; to redirect,

try:

window.location.replace(url);

after using replace() the current page will not be saved in session history, meaning the user won't be able to use the Back button to navigate to it.

这篇关于在Javascript中,我如何“清除”后面(历史-1)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆