JA vasc ript Return to the previous page and refresh the page implementation method

Source: Internet
Author: User

1. Ja vasc ript returns to the previous page history.go (-1), returns two pages: History.go (-2);

2. History.back ().

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

4. Window.history.go (returns the first few pages, also can use the visited URL)

Cases:

[Code]XM L Code:

<a href= "ja vasc ript:history.go (-1);" > Up one page </a>

Response. Write ("<sc ript language=ja vasc ript>")

Response. Write ("If" (!confirm (' Complete task? ')) {History.back ();} ")

Response. Write ("</sc ript>")

Response. Write ("<sc ript language=ja vasc ript>history.go ( -1); </SC ript>")

<a href= "ja vasc ript:history.go (-1);" > Up one page </a>

Page jump: On click= "window.location.href= ' list.php '"

P.S.

Tips (JS reference js):

[Code]XM L Code:

<SC ript type=text/ja Vasc ript>

<!--

if (typeof swfob ject = = "undefined") {

document.write (' <scr ' + ' IPT type= "Text/ja vasc ript ' src= '/sc ripts/swfob ' ject-1.5.js ' ></scr ' + ' ipt> ');}

-->

</SC ript>

JA vasc ript Refresh 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. Page Automatic refresh: Add the following code to the <head> area

<me ta http-equiv= "refresh" content= ">"

20 of which means that the page is refreshed every 20 seconds.

2. Page Automatic Jump: Add the following code to the <head> area

<me ta http-equiv= "Refresh" content= "20;url=http://www.php2.cc" >

20 of which refers to 20 seconds after the jump to the http://www.php2.cc page

3. Page automatically refresh JS version

[Code]XM L Code:

1<SC ript language= "ja vasc ript" >

2 function Myrefresh ()

3 {

4 Window.location.reload ();

5}

6 settimeout (' Myrefresh () ', 1000); Specify 1 seconds to refresh once

7 </SC ript>

How PHP output refreshes the parent window script statement

1. Echo "<SC ript>opener.location.reload (); </sc ript>";

2. echo "<sc ript>opener.window.location.href = opener.window.location.href;</sc ript>";

3. Echo "<SC ript language=ja vasc ript>opener.window.navigate (' You want to refresh the page. php '); </SC ript>"

How to refresh the page that contains the frame with

[Code]XM L Code:

<SC ript Language=ja Vasc ript>

Parent.location.reload ();

</SC ript>

child window refreshes parent window

[Code]XM L Code:

<SC ript Language=ja Vasc ript>

Self.opener.location.reload ();

</SC ript>

(or <a href= "ja vasc ript:opener.location.reload ()" > Refresh </a>)

How to refresh another frame's page with

[Code]XM L Code:

<SC ript Language=ja Vasc ript>

Parent. Another FR AmeID.location.reload ();

</SC ript>

If you want to close the window or refresh when you want to open windows, call the following statement in <body>.

<body on load= "Opener.location.reload ()" > Refresh when opening windows

<body on unload= "Opener.location.reload ()" > Refresh at shutdown

<SC ript language= "ja vasc ript" >

Window.opener.document.location.reload ()

</SC ript>

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.

Tags Index: