Prevent logon pages from appearing in frames and prevent logon to Frames

Source: Internet
Author: User

Prevent logon pages from appearing in frames and prevent logon to Frames

When using the nested frame page for development, the logon page appears on the frame page when the server is restarted,

Therefore, you need to use js to determine the current address information on the logon page, and then jump to the separate logon page.


The js Code is as follows:

$ ("Document"). ready (function () {// prevent the logon page from appearing in the frame if (top. location! = Self. location) {// alert (top. location); // alert (self. location); top. location. href = self. location. href ;}});


After frameset configures loginUrl in webconfig, three logons will appear on the page, that is, each frame will have

Add the following code to the login page:

<Script language = "javascript">
// Prevent a login page for each iframe
Function gototop ()
{
If (top)
{
If (top. location! = Self. location)
{
Top. location = self. location;
}
}
}
</Script>

The struts2 login interceptor page Jump problem, the use of frameset

To open the entire window, you can enter a JSP center jump page after interceptor verifies that the session is invalid. Then, the page automatically enters the logon page.
The sample JSP is as follows:
<% @ Page language = "java" contentType = "text/html; charset = GBK" errorPage = "/default_error.jsp" %>
<%
String path = request. getContextPath ();
String basePath = request. getScheme () + "://"
+ Request. getServerName () + ":" + request. getServerPort ()
+ Path + "/";
%>
<Html>
<Head>
<Script type = "text/javascript">
Window. top. location. href = "<% = basePath %> login. jsp ";
</Script>
</Head>
</Html>

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.