JavaScript document.referrer

Ali*_*ley 3 javascript

我有两个网页

<html>
  <body>
    <p><a href="page2.html">Link</a></p>
  </body>
</html>
Run Code Online (Sandbox Code Playgroud)

第二页.

<html>
  <body>
    <script type="text/javascript">
      document.write(document.referrer);
    </script>
  </body>
</html>
Run Code Online (Sandbox Code Playgroud)

第二页总是空白,它似乎没有拿起推荐人,任何想法是为什么?

Pek*_*ica 9

在IE中,document.referrer仅适用于http://资源,不https://file://的.也许那是你的问题.

编辑:更多的情况下 IE没有传递它.

  • 这几乎肯定是问题,因为我在本地测试,当我在服务器上尝试它时,它是一个https://.最好查看网址中的查询字符串. (2认同)