如何从多个框架注销 [英] how to logout from multiple frames

查看:191
本文介绍了如何从多个框架注销的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个有4帧的页面,代码如下:

 < frameset id = framset_page rows =30 ,*cols =*border =0> 
< frame name =topFrameid =topFramenoresize scrolling =NOsrc =topFrame.jsp>
< frameset cols =200,50,*>
< frame src =FramesetLeftFrame.jsp/>
< frame src =middle.html/>
< frame src =FramesetRightFrame.jsp/>
< / frameset>
< / frameset>

topFrame包含一个注销按钮。但是当我点击注销按钮时,它只是退出topFrame其他人仍然是一样的,我可以退出其他框架吗?在topFrame中编写代码似乎不起作用。感谢您!

您可以将 target =_ top添加到您的链接中,或者您可以使用javascript来使用顶部框架进行导航:

  self.parent.location =URL注销; 

示例:

 < a href =logout.phptarget =_ top>注销< / a> 

< a href =javascript://onclick =self.parent.location ='logout.php'>注销< / a>

其他替代方法是,在您的注销页面中添加一个JavaScript代码以删除重定向文档的框架到顶部框架:

 < script type =text / javascript> 
if(self.parent.frames.length!= 0){
self.parent.location = document.location.href;
}
< / script>


i have a page which has 4 frames the code is as below

<frameset id = framset_page rows="30,*" cols="*" border="0">
  <frame name="topFrame" id="topFrame" noresize scrolling="NO" src="topFrame.jsp">
   <frameset  cols="200,50,*">
    <frame src="FramesetLeftFrame.jsp" />
    <frame src="middle.html" />
      <frame src="FramesetRightFrame.jsp" />
   </frameset>
</frameset>

the topFrame include a logout button.but what when i click the logout button,it just exit the topFrame others remain the same.how can i exit other frames either?writing code in the topFrame seems not work.thank you!

解决方案

You can add target="_top" to your link or you can use javascript to navigate using your top frame:

self.parent.location= "URL TO logout";

Examples:

<a href="logout.php" target="_top">Logout</a>

<a href="javascript://" onclick="self.parent.location='logout.php'">Logout</a>

Other alternative is, into your logged out page, add a javascript code to remove the frames redirecting your document to the top frame:

<script type="text/javascript"> 
    if (self.parent.frames.length != 0){
        self.parent.location=document.location.href;
    }
</script>

这篇关于如何从多个框架注销的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆