Today in an app test to use to return to the previous source page of a function, but after testing history.back () found in IE effective in Firefox and chrome invalid, below we see how to solve the problem.
The original notation is History.back () as follows
Htm
<div class= "btn1" ><a href= "#" id= "Calcelbtn" > Cancel </a></div>
JS Code
$ (' #calcelbtn '). Click (function () {
History.back ();
})
After the test found in IE can be used, in Firefox and Chrome is invalid, later Baidu discovered to be in accordance with the following method is not invalid in Firefox and Chrome support.
FireFox:
Just change it to the following way:
<a href= "#" onclick= "Window.history.back ()" > Back </a>
Chrome:
Chrome is more difficult than Firefox:
<a href= "#" onclick= "Window.history.back (); return false; " > Back </a>
Human analysis: For Chrome, the first execution of Window.history.back (), after the completion of the execution of the href= "#", it cannot be returned. Plus return false will no longer execute href= "#" Okay, let's do some fixing.
$ (' #calcelbtn '). Click (function () {
Window.history.back ();
return false;
})
JavaScript history.back () invalid solution in Firefox and Chrome