问题描述:判断iframe中的显示页面是不是最顶层的页面,如:判断登录;页面应该在最外层页面显示,而不是加载在iframe中显示。
if(self!=top){
//不是顶层页面
alert("您的登陆已超时,请重新登陆!");
top.location.href="../../index.jsp";
}
在使用该js是应该在 页面载入时调用。
<script language="javascript">
window.οnlοad=function(){
alert("页面载入时,自动调用js函数。");
}
</script>