首页 > 网站 > WEB开发 > 正文

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

2024-04-27 15:03:13
字体:
来源:转载
供稿:网友

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

if(self!=top){      //不是顶层页面        alert("您的登陆已超时,请重新登陆!");        top.location.href="../../index.jsp";  }在使用该js是应该在 页面载入时调用。

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


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表