JavaScript and the history.back() method

JavaScript and the history.back() method

本文关键字:method back history and the JavaScript      更新时间:2023-09-26

如果用户从外部网站访问我的主页www.example.com,将显示警报。。。但如果用户来自我网站的内部页面,则不会显示警报。

我认为history.back()方法在我的情况下很有用,但我不知道如何使用它来解决这个问题。

有些情况下会隐藏referer,例如您的网站的书签

这将在大多数情况下工作

console.log(document.referrer)
if (document.referrer.indexOf(location.host) == -1) {
  document.write("Welcome to my site")
}

有一个可选的http头,名为"referer",我用它来检测调用的来源。

W3.org