最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - how to logout from multiple frames - Stack Overflow

programmeradmin5浏览0评论

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!

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!

Share Improve this question asked Aug 12, 2010 at 6:28 huanglihuangli 4549 silver badges26 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 5

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>

This worked for me. By closing the top frame using the following code.

function logout() {
  window.top.document.location ="../index.php";
}

this directs the page to the index page.

Please post the code for your logout button, form. However, if it is a form or a link/button, setting target="_top" might do what you're looking for.

发布评论

评论列表(0)

  1. 暂无评论