Exit the frame framework and exit the frame framework.

Source: Internet
Author: User

Exit the frame framework and exit the frame framework.

The traditional system interface has an iframe page. When you exit the system or the session expires or illegal requests, you must redirect the current page to the logon page. For example, you can click the Logout button to top the list. in jsp, the method is: <a href = ".. /login/action_logout.do "> exit the system </a> and you will find that the top is refreshed. the iframe above jsp, the other two are still, of course, this is not allowed. There are several solutions

You can click a hyperlink to jump to the logon page, or click a page element to trigger a js event to redirect the current page.
1. Use target = "_ parent" in the hyperlink property ".
Add the target attribute <a href = ".. To the hyperlink ".. /login/action_logout.do "target =" _ parent "> exit the system </a>. The principle is to replace the current parent form with the target page instead of the current form.
Description of target attribute values:
_ Blank: new window, _ self: Same window, _ parent: parent window, _ top: First window
2. Use js
1) <a href = "#" onclick = top. location. replace ("logout. action")> exit </a>
In the logout () function, clear the session. The returned logon page is displayed in full screen. the principle is equivalent to replacing the requested page with the top frame of the current page before the request is sent, so that the returned page should replace the content of the whole page.

2) Add a script to login. jsp.

?
12345 function window.onload()    {        if(window.parent.length>0)         window.parent.location=location;    }

Or

?
12345 <script type="text/javascript"> if (top.location !== self.location) {    top.location=self.location;}</script>

Or

?
1234 <script language="JavaScript">   <span style="white-space:pre">    </span>if (window != top)   <span style="white-space:pre">    </span>top.location.href = location.href;   </script>

When the login page loads data in the frame, this js Code is triggered to determine whether it is a top-level form and automatically jumps.

The difference between the two methods is that the request is processed before the request is submitted, and the other is processed after the request is returned.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.