HTTP 引荐来源网址以及 IE7 和 IE8

发布于 2024-08-25 14:54:08 字数 392 浏览 2 评论 0原文

您好,我已尝试以下方法在 MSIE / IE7 和 IE8 中查找引荐来源网址,但每次都返回空白;

PHP:

<?
echo $_SERVER['HTTP_REFERER'];
?>

JAVASCRIPT:

document.write('Thanks for visiting from ' + document.referrer);

有谁知道问题可能是什么吗?我正在使用另一个域上的页面上的 document.location 来引用,并且可以与除 MSIE 之外的所有其他浏览器一起正常工作。

任何帮助都会很棒!

Hi i've tried the following to find the referrer in MSIE / IE7 and IE8 but its returning blank each time;

PHP:

<?
echo $_SERVER['HTTP_REFERER'];
?>

JAVASCRIPT:

document.write('Thanks for visiting from ' + document.referrer);

Does any know what the issue could be I'm referering using document.location from a page on another domain and work fine with all other browsers minus MSIE.

Any help would be great!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

橘亓 2024-09-01 14:54:08

HTTP 协议不需要 HTTP Referer 标头

  • 它是仅作为信息发送
  • 浏览器可以或不能发送它(这可以解释为什么您可以在某些浏览器中获取它,而在其他浏览器中却无法获取它)
  • 我想,在某些情况下,某些防火墙/安全软件可以将其删除(几年前,如果我没记错的话,我已经看到过)
  • 它可以被用户轻松伪造,

这意味着< strong>您的应用程序不能依赖 Referer:您可以使用它来提供一些附加功能,但您的应用程序必须能够工作,即使它不存在或不正确。

The HTTP Referer header is not required by the HTTP Protocol :

  • It is only sent as an information
  • The browser can, or cannot, send it (Which would explain why you're getting it with some browsers, and not getting it with some others)
  • Some firewall / security software could remove it, I suppose, in some situations (I've seen that, some years ago, if I remember correctly)
  • It can be forged easily by the user

Which means that you cannot rely on the Referer for your application : you can use it to provide some additionnal functionnality, but your application must work even if it's not there, or not correct.

那片花海 2024-09-01 14:54:08

HTTP_REFERRER 在 IE 浏览器中不起作用,但它适用于所有浏览器,如 mozilla、safari、opera 等... Referrer 方法在 IE 中无法识别,当我们将其应用于 IE 时,它将返回 null。实际上使用 HTTP_REFERRER 本身并不是一个正确的标准,因为我们不能期望它是否有效,因为它不是标准的 HTTP HEADER。

HTTP_REFERRER does't work in IE browser it works fine for all browsers like mozilla, safari, opera etc... Referrer method doesn't recognize in IE it will return null when we apply it for IE. Actually using HTTP_REFERRER itself is not a right criteria because we can't expect it will work or not as it is not a standard HTTP HEADER.

﹏半生如梦愿梦如真 2024-09-01 14:54:08

您可以尝试以下方法:

    var referLink = document.createElement('<a href="' + theUrl + '" target="' + theWindow + '"></a>');
    document.body.appendChild(referLink);
    referLink.click();

Here's a hack you might try:

    var referLink = document.createElement('<a href="' + theUrl + '" target="' + theWindow + '"></a>');
    document.body.appendChild(referLink);
    referLink.click();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文