JavaScript effects forward, back (back to previous level)

Source: Internet
Author: User

Add forward on the page, back (return to the previous level) feature:


Way one: Using functions

<SCRIPT>
function GoBack () {
 history.go (-1);// Returns or History.back ();
}
function Go () {
history.go (1);// Forward or History.forward ();
}
</SCRIPT>


Way two:


<a href= "Javascript:history.go (1)" > Forward </a>

<a href= "Javascript:history.go ( -1)" > Back </a>


Easy to doubt the place:

Each page can be set back forward button, only this page jumps to other pages. The Forward button on this page is valid (with the forward direction),

Only the Back button on this page will be valid if the other page jumps to this page ( know the way to go back to the original path ).

(as the forward and backward to have a target direction)



<title> forward, back </title>
<script>
function GoBack () {
History.go (-1);//Return or history.back ();
}
function Go () {
History.go (1);//Forward or history.forward ();
}
</script>
<body>
<a href= "damel8.html" >go to Damel8.html</a>

<br/>

<!--assume that this page (recorded as B) will be returned to the original a page by clicking on the Back button by <a href= "" > </a> by other pages (recorded as page a); Jump back to page a. Suppose you click the Forward button (javascript:history.go (1)) on page A to jump to page B.


Popular speaking:

A page jumps to page B via <a href= "" > </a> etc.

Click the Back button on page B to jump back to page a

Click the Forward button on page A to jump back to page B.


Easy to doubt the place:

Each page can be set back forward button, only this page jumps to other pages, this page of the Forward button is effective (with the direction of the forward),

Only the Back button on this page will be valid if the other page jumps to this page ( knowing the way to go back to the original path ),

(because the forward and backward direction should have a goal.)

。。 Know the way to come back to the original road,)

-

Method One: Use href

<br/>

<a href= "Javascript:history.go (1)" > Forward </a>

Mode two: using function calls

<br/>

<input type= "button" onclick= "GoBack ()" value= "Back"/>
<br/>
</body>

JavaScript effects forward, back (back to previous level)

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.