SSH系列:(21)Session过期,登录页面嵌套的问题
在系统中使用了frameset,当前用户的系统登录信息失效后;如果再点击左边的菜单,那么在右边的显示登录页面,而正确的应该是整个页面返回到登录页。
解决这个问题:应该在跳转到登录页面中使用js脚本判断,是否当前页面在框架内,即当前页面的窗口是否是顶级窗口,如果是子窗口的话;可以直接刷新父窗口的地址则会自动地整个页面跳转为登录页。
<scripttype="text/javascript">if(window!=window.parent){window.parent.location.reload(true);}</script>
或许下面的更合适
//解决子框架嵌套的问题if(window.self!=window.top){window.top.location.reload(true);}
window.parent说明: window.parent能获取一个框架的父窗口或父框架。顶层窗口的parent引用的是它本身,可以用这一点特性来判断这个窗口是否是顶层窗口。
地址:http://blog.csdn.net/zdwzzu2006/article/details/6047632
在应用有frameset或者iframe的页面时,parent是父窗口,top是最顶级父窗口(有的窗口中套了好几层frameset或者iframe),self是当前窗口, opener是用open方法打开当前窗口的那个窗口。
window.self
功能:是对当前窗口自身的引用。它和window属性是等价的。
语法:window.self
注:window、self、window.self是等价的。
window.top
功能:返回顶层窗口,即浏览器窗口。
语法:window.top
注:如果窗口本身就是顶层窗口,top属性返回的是对自身的引用。
window.parent
功能:返回父窗口。
语法:window.parent
注:如果窗口本身是顶层窗口,parent属性返回的是对自身的引用。
在框架网页中,一般父窗口就是顶层窗口,但如果框架中还有框架,父窗口和顶层窗口就不一定相同了。
判断当前窗口是否在一个框架中:
<script type="text/JavaScript">
var b =window.top!=window.self;
document.write( "当前窗口是否在一个框架中:"+b );
</script>
你应当将框架视为窗口中的不同区域,框架是浏览器窗口中特定的部分。一个浏览器窗口可以根据你的需要分成任意多的框架,一个单个的框架也可以分成其它多个框架,即所谓的嵌套框架。
地址:https://developer.mozilla.org/en-US/docs/Web/API/Location/reload
Location.reload()TheLocation.reload()
method reloads the resource from the current URL. Its optional unique parameter is aBoolean
, which, when it istrue
, causes the page to always be reloaded from the server. If it isfalse
or not specified, the browser may reload the page from its cache.
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。