防止网站被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属性