【问题标题】:Knowing the Source of a website? [duplicate]了解网站的来源? [复制]
【发布时间】:2016-02-06 10:59:26
【问题描述】:

我创建了一个网站,它会像这样重定向到另一个网站:

<!DOCTYPE HTML>
<html lang="en-US">
    <head>
        <meta charset="UTF-8">
        <title>Site 1</title>
        <meta http-equiv="refresh" content="1;url=http://page2.com">
        <script type="text/javascript">
            window.location.href = "http://page2.com"
        </script>
    </head>
    <body>
        If you are not redirected automatically, click
        <a href='http://page2.com'>here</a>.
    </body>
</html>

现在在接收页面上; page2.com,我怎么知道用户是来自 page1 还是其他页面?如果它们来自其他来源,我不需要知道。我只需要知道它们是否来自我的重定向页面。

【问题讨论】:

  • 您可以检查“referrer”HTTP 标头,但这并不能保证,并且可以通过浏览器扩展等轻松修改。
  • 有更“安全”的方法吗?

标签: javascript html


【解决方案1】:
<script>
var x = document.referrer;
alert(x);
if (x == 'http://stackoverflow.com/questions/35236796/knowing-the-source-of-a-website/35236811')
alert('hi stackoverflower');
</script>

示例:http://ec2-52-49-115-131.eu-west-1.compute.amazonaws.com/test.php

【讨论】:

    猜你喜欢
    • 2013-03-08
    • 2012-05-16
    • 1970-01-01
    • 2022-11-21
    • 1970-01-01
    • 1970-01-01
    • 2019-02-03
    • 1970-01-01
    • 2019-01-17
    相关资源
    最近更新 更多