When talking about the differences between the two methods, we need to combine the mechanisms of window. History. Go (-1); wondow. History. Back.
The two methods determine the page to jump to based on the request recorded by the server.
Window. Location. href ("test. jsp"); is a jump request sent to the server
Window. Location. Replace ("test. jsp"); is a jump that does not send a request to the server.
Therefore, window. History. Go (-1); wondow. History. Back (); works with window. Location. href ("test. jsp"); Okay is used.
Example of the following three pages
<! Doctype HTML public "-// W3C // dtd html 4.0 transitional // en"> <br/> <HTML> <br/> <pead> <br/> <title> new document </title> <br/> <meta name = "generator" content = "editplus"> <br/> <meta name = "author" content = ""> <br/> <meta name = "keywords" content = ""> <br/> <meta name = "Description" content = ""> <br/> </pead> <br/> <body> <br/> This is 1 JSP <br/> </body> <br/> </ptml> <br/>
<! Doctype HTML public "-// W3C // dtd html 4.0 transitional // en"> <br/> <HTML> <br/> <pead> <br/> <title> new document </title> <br/> <meta name = "generator" content = "editplus"> <br/> <meta name = "author" content = ""> <br/> <meta name = "keywords" content = ""> <br/> <meta name = "Description" content = ""> <br/> </pead> <br/> <body> <br/> This is 2 JSP <br/> <input type = "button" value = "go 3 JSP by window. location. replace "onclick =" window. location. replace ('3. JSP '); "> <br/> <input type =" button "value =" go 3 JSP by window. location. href "onclick =" window. location. href ('3. JSP '); "> <br/> </body> <br/> </ptml> <br/>
<! Doctype HTML public "-// W3C // dtd html 4.0 transitional // en"> <br/> <HTML> <br/> <pead> <br/> <title> new document </title> <br/> <meta name = "generator" content = "editplus"> <br/> <meta name = "author" content = ""> <br/> <meta name = "keywords" content = ""> <br/> <meta name = "Description" content = ""> <br/> </pead> <br/> <body> <br/> This is 3 JSP <br/> <input type = "button" value = "back by window. history. go (-1) "onclick =" window. history. go (-1); "> <br/> <input type =" button "value =" back by window. history. back () "onclick =" window. history. back (); "> <br/> </body> <br/> </ptml> <br/>