页面历史记录 - 后退按钮存在? [英] Page history - back button exists?

查看:137
本文介绍了页面历史记录 - 后退按钮存在?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以检查history.go(-1)是否有值?我知道你不能直接访问history.previous。

Is it possible check if there is a value for history.go(-1)? I know you can't access history.previous directly.

我试图远离document.referrer,因为我知道它可以在某些情况下被阻止。

I am trying to stay away from document.referrer because I know it can be blocked in some instances.

这是我想要做的。我有一个错误页面,在这个页面上我想要一个BACK按钮(如果它不是历史上唯一的项目)或一个关闭按钮(如果是)。

Here is what I am trying to do. I have an error page, on this page I would like to either have a BACK button (if it's not the only item in history) or a close button (if it is).

推荐答案

if (history.length) {
    //There is history to go back to
    history.go(-1);
}    

这篇关于页面历史记录 - 后退按钮存在?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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