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
- <divclass= "Oper_context_view" >
- <aid= "Btn_exit" class= "btn" href= "javascript:void (0);" > Back </a>
- </div>
<div class= "Oper_context_view" > <a id= "Btn_exit" class= "btn" href= "javascript:void (0);" > Back </a> </div>
JS Code
- $ ("#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
- });
$ ("#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