判断当前页面是不是顶层页面

来源:互联网 发布:淘宝秒杀最准的时间 编辑:程序博客网 时间:2024/06/07 16:08

问题描述:判断iframe中的显示页面是不是最顶层的页面,如:判断登录;页面应该在最外层页面显示,而不是加载在iframe中显示。

if(self!=top){      //不是顶层页面        alert("您的登陆已超时,请重新登陆!");        top.location.href="../../index.jsp";  }

在使用该js是应该在 页面载入时调用。

<script language="javascript"> window.onload=function(){  alert("页面载入时,自动调用js函数。");
}</script>


0 0