JS Page Jump

Source: Internet
Author: User

JS Way of Page jump
1.window.location.href Way
<script language= "javascript" type= "Text/javascript" >
Window.location.href= "Target.aspx";
</script>

2.window.navigate Way Jump
<script language= "JavaScript" >
Window.navigate ("target.aspx");
</script>

3.window.loction.replace way to achieve page jump, note the difference from the first way
<script language= "JavaScript" >
Window.location.replace ("target.aspx");
</script>
There are 3 JSP pages (1.aspx, 2.aspx, 3.aspx), into the system default is 1.aspx, when I enter 2.aspx, 2.aspx inside with Window.location.replace ("3.aspx");

With the use of Window.location.href ("3.aspx");

There is no difference from the user interface, but when the 3.aspx page has a "back" button, call Window.history.go (-1); Wondow.history.back () method, a little bit of this return button will return to the 2.aspx page, the difference is out, when using Window.location.replace ("3.aspx"); On the 3.aspx page, call Window.history.go ( -1) in the 3.aspx page, Wondow.history.back (), and the method is not good enough to return to 1.aspx.

4.self.location way to achieve page jump, and the following top.location there is a small difference
<script language= "JavaScript" >
self.location= ' target.aspx ';
</script>

5.top.location
<script language= "JavaScript" >
top.location= ' target.aspx ';
</script>

6. Do not recommend this way to jump
<script language= "JavaScript" >
Alert ("return");
Window.history.back (-1);
</script>

Meta-mode implementation jump (Content = 3 units is seconds)
<meta Http-equiv=refresh content=3; Url= "Http://www.dayanmei.com" >

Summary two:

1. Javascript returns to previous page History.go (-1), returns two pages: History.go (-2);

2. History.back ().

3. Window.history.forward () return to next page

4. Window.history.go (return to page or use the URL you have visited)

Cases:
<a href= "Javascript:history.go (-1);" > Up one page </a>

Response. Write ("<script language=javascript>")
Response. Write ("if (!confirm (' Complete task? ')") {History.back ();} ")
Response. Write ("</script>")
Response. Write ("<script language=javascript>history.go ( -1);</script>")
<a href= "Javascript:history.go (-1);" > Up one page </a>

Page Jump: onclick= "window.location.href= ' list.aspx '"

P.S.
Small tricks (JS reference js):

[JavaScript]View Plaincopy
    1. <mce:script type=text/javascript><!--  
    2.    
    3. if  (typeof  swfobject ==  "undefined")  {   
    4. document.write ( ' <SCR '  +  ' ipt type= "text/ JavaScript " src="/scripts/swfobject-1.5.js "></scr '  +  ' ipt> ');}   
    5. // --></mce:script>    


JavaScript refreshes the page in several ways:
1 history.go (0)
2 Location.reload ()
3 location=location
4 Location.assign (location)
5 Document.execcommand (' Refresh ')
6 Window.navigate (location)
7 Location.replace (location)
8 document. Url=location.href

Ways to automatically refresh pages:
1. Automatic page refresh: Add the following code to the <meta http-equiv= "Refresh" content= ">"
20 refers to a refresh of the page every 20 seconds.

2. Page Auto-jump: Add the following code to the <meta http-equiv= "Refresh" content= "20;url=http://www.wyxg.com" >
Where 20 means jump to http://www.wyxg.com page after 20 seconds

3. Page automatically refresh JS version

[C-sharp]View Plaincopy
    1. <mce:script language="JavaScript" ><!--
    2. function Myrefresh ()
    3. {
    4. Window.location.reload ();
    5. }
    6. SetTimeout (' Myrefresh () ', 1000); //Specify 1 seconds to refresh once
    7. --></mce:script>



ASP. NET how to Output Flush parent window script statements
1. This.response.write ("<script>opener.location.reload ();</script>");

2. This.response.write ("<script>opener.window.location.href = opener.window.location.href;</script>") ;


3. Response.Write ("<script language=javascript>opener.window.navigate (" You want to refresh the page. asp ');</script> ")


JS Refresh Framework Script statement

How to refresh the page that contains the frame
<script language=javascript>
Parent.location.reload ();
</script>

child window refreshes parent window
<script language=javascript>
Self.opener.location.reload ();
</script>
(or <a href= "javascript:opener.location.reload ()" > Refresh </a>)

How to refresh another frame's page with
<script language=javascript>
Parent. Another FrameID.location.reload ();
</script>

Call the following statement in <body> if you want to refresh the window or refresh it when you want to open it.

[JavaScript]View Plaincopy
    1. <body onload="opener.location.reload ()" > Windows refresh
    2. <body onunload="opener.location.reload ()" > Refresh when off
    3. <mce:script language="javascript" ><!--
    4. Window.opener.document.location.reload ()
    5. --></mce:script>

Reference: http://blog.csdn.net/kongjing0815/article/details/5808063

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.