HTTP_REFERER有效和无效的情况

HTTP_REFERER有效和无效的情况

【准备】
test.php文件

echo $_SERVER['HTTP_REFERER'];

【有效的情况】
1、以iframe 形式调用地址,如下所示

2、以window.open调用,打开新页面
window.open(url);

3、使用window.location.replace在Firefox 和Chrome下可以获取HTTP_REFERER

window.location.replace(url);

4、使用window.location.href在Firefox 和Chrome下可以获取HTTP_REFERER
window.location.href = url;

5、使用A标签跳转可以获取HTTP_REFERER

【无效的情况】
1、使用函数 file_get_contents或file等函数调用URL地址,这个地址所在的文件无法获取HTTP_REFERER

2、使用window.location.replace在IE6、IE7、IE8下无法获取HTTP_REFERER
window.location.replace(url);

3、使用window.location.href在IE6、IE7、IE8下无法获取HTTP_REFERER
window.location.href = url;

HTTP_REFERER有效和无效的情况》上有2条评论

发表评论

电子邮件地址不会被公开。 必填项已用*标注


*

您可以使用这些HTML标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>