当前位置:编程学习 > 网站相关 >>

防止网站外部[iframe]调用js,php方法

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>防止网站外部调用js,php方法</title>
</head>

这是一段简单的防止网站被iframe调用的js方法
<script>
if (top.location != self.location)top.location=self.location;
var isindex=1;
</script>

下面一段php
<?php

$url = 'www.226511.cn';
if( $_SERVER['HTTP_HOST'] <> $url )
{
 header("location:http://www.226511.cn");
}
?>

<body>
</body>
</html>

补充:网页制作,设计基础 
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,