以前防止页面被iframe使用的是这段代码
但是在Firefox里你会发现页面会一直不停的在刷. 页面根本没法用.
这里是因为firefox windows.top如果没有那么就是空,在IE下windows.top就是本窗口 页面不断的刷新 不断的运行这段js代码这就造成了一个死循环,也是为什么页面一直在刷新.
所以我更改了方式,使用下面这段代码 兼容firefox
这样问题就解决了.
还有用php来实现
$url = $_server['http_host'];
if( $url != 'www.jb51.net' )
{
exit();
}
?>
asp实现代码
yuming=Request.ServerVariables("SERVER_NAME")
if yuming"www.jb51.net" then
response.redirect "http://www.jb51.net"
end if
其它语言的原理大同小异,大家可以获取环境变量来得到。
希望这里能够帮助到大家.
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn