Several Methods for page Jump using JavaScript

Source: Internet
Author: User

Overview

I believe many web developers know thatProgramThere are many ways to jump between pages, but effective jumps get twice the result with half the effort. Below are some of the Javascript jump methods I used during the development process, share it with you.

 

First: directly jump to add Parameters

 
<Script language = "JavaScript" type = "text/JavaScript">
Window. Location. href = "login. jsp? Backurl = "+ window. Location. href;
</SCRIPT>

Direct jump without parameters:

 

 
<SCRIPT> window. Location. href = 'HTTP: // www.baidu.com '; </SCRIPT>

 

Type 2: return to the previous preview Interface

 

<Script language = "JavaScript">
Alert ("return ");
Window. History. Back (-1 );
</SCRIPT>


Label nesting:

 
<A href = "javascript: history. Go (-1)"> return to the previous step. </a>
<A href = "<% = request. servervariables (" http_referer ") %>"> return to the previous step </a>



Third: the frame is not valid when the webpage is redirected...

 
<Script language = "JavaScript">
Window. navigate ("Top. jsp ");
</SCRIPT>

Type 4: the framework is invalid when you specify the webpage to jump ..

 
<Script language = "JavaScript">
Self.location+'top.htm ';
</SCRIPT>

 

Category 5: specify that the webpage is valid for the framework ..

 
<Script language = "JavaScript">
Alert ("illegal access! ");
Top. Location = 'xx. aspx ';
</SCRIPT>

 

 

Method 6: click the button to add an event jump ..

 
<Input name = "pclog" type = "button" value = "go" onclick = "location. href = 'login. aspx '">


7. open in a new window:

 
<A href = "javascript:" onclick = "window. open ('login. aspx ', '', 'height = 500, width = 611, scrollbars = Yes, status = Yes')"> open a new window </a>


Application instance:

 <  Head  >  
< Script Language = "JavaScript" >

Function Old_page ()
{
Window. Location = " Login. aspx "
}
Function Replace ()
{
Window. Location. Replace ( " Login. aspx " )
}
Function New_page ()
{
Window. Open ( " Login. aspx " )
}
</ Script >
</ Head >
< Body >
< Input Type = "Button" Onclick = "New_page ()" Value = "Open s in new window" />
< Input Type = "Button" Onclick = "Old_page ()" Value = "Backward after redirection" />
< Input Type = "Button" Onclick = "Replace ()" Value = "No backend function after jump" />
</ Body >

 

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.