Window.history Back/go/forward/reload

Source: Internet
Author: User

Window.history.go (-1) Back and refresh the page

Windows Window object (History) History.go (), History.back (), History.forward ().

Because Windows object references are not required. So windows.history.go () = = History.go ().

The Go () method has only one parameter, which can be an integer and a negative number. If it is positive, go ahead. Negative numbers are backwards. (equivalent to the difference between forward and back)

So, back one page, use the following code: (back multiple pages, just change the parameters of Go)

Window.history.go (-1);

To advance a page, you only need to use a positive number;

History.go (1);

In addition, the same operation can be achieved with the back () and Forward () methods:

History.back (); Back off

History.forward (); Forward

You can also view the number of pages in history with the length property:

History.length;

The difference between 2.history.go (-1) and History.back ()

History.go (-1) indicates fallback and refresh. Change as the data changes

History.back () simply returns to the previous page.

Cases:

HTML code
    1. <divclass= "Oper_context_view" >
    2. <aid= "Btn_exit" class= "btn" href= "javascript:void (0);" > Back </a>
    3. </div>
<div class= "Oper_context_view" >           <a id= "Btn_exit" class= "btn" href= "javascript:void (0);" > Back </a>  </div>
JS Code
    1. $ ("#btn_exit"). Bind ("click", Function () {  
    2.                window.location.reload ();     //Refresh
    3.                window.history.go (1);          //forward
    4.                window.history.go ( -1);         //return + Refresh
    5.                Window.history.forward ();   //forward
    6.                window.history.back ();        //return
    7.    });    
  $ ("#btn_exit"). Bind ("click", Function () {                 window.location.reload ();    Refresh                 window.history.go (1);         Forward                 Window.history.go ( -1);        return + refresh                 window.history.forward ();  Forward                 Window.history.back ();       Return     

Window.history Back/go/forward/reload

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.