防止网站被iframe调用

其它A网站调用B网站的时候:

A站调用:

<iframe width="100%" height="100%" src="test.html" frameborder="0"></iframe>

B站添加以下脚本:

if(window != window.top){  //判断窗口是否就是顶层窗口
  window.top.location.href=window.location.href;  //将顶层窗口跳转到iframe页
}

 

参考window对象的top属性

http://www.w3school.com.cn/jsref/prop_win_top.asp

posted @ 2014-04-22 15:19  华生_  阅读(599)  评论(0编辑  收藏  举报