Good day to all.
Interested in the question of why the JScript'a function of window.history.back() does not work in the Chome browser?
Or for Chrome what crutch is needed for this function?

  • one
    Are you sure that the function does not work? How do you use what you see in the end? - Alex Kapustin
  • Check out the console. You may have been sealed in the function name. In Chrome, window.history.back () works fine. Or maybe there are simply no previous addresses in history. - fori1ton
  • Just checked window.history.back () in the Chrome console. Everything is working. - Zhukov Roman
  • Here is my event handler:> <script language = "javascript">>> function goBack ()>> {>> window.history.back ()>>}>> </ script>>>> ... < tr>>> <td colspan = "2" align = "center">>> <a href = "" onclick = "goBack ()" style = "text-decoration: none; color: # ffcc00; font: bold 14px '' "> & # 60 & # 60 BACK </a>>> </ td>>> </ tr> ... It seems that everything is correct, but it does not work on LAN or on hosting. (now I will try from a laptop ...) - I_CaR


3 answers 3

Use the following directive:

 <script> function goBack() { history.go(-1); } </script> 

and

 <a href="javascript:goBack()">Back</a> 
  • did not help ... - I_CaR
  • Chrome Version 24.0.1312.57 m Works like a clock: a.html <! DOCTYPE html PUBLIC "- // W3C // DTD XHTML 1.0 Transitional // EN" " w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd " > <html xmlns = " w3.org/1999/xhtml "> <head> </ head> <body> <a href="b.html"> go </a> </ body> </ html> b. html <! DOCTYPE html> <html> <head> <script> function goback () {history.go (-1); } </ script> </ head> <body> <a href="javascript:goback()"> Back </a> </ body> </ html> - void
  • The difference in HTML In your example, through the event: <a href="" onclick="goBack()" style=" text-decoration:none; color:#ffcc00; font:bold 14px '';"> & # 60 & # 60 BACK </a> In my passed through href: <a href="javascript:goBack()"> Back </a> - void
  • Thank! EARNED! Immediately just did not notice that through href - I_CaR

Try using <button onclick = 'history.back ();'> Back </ button>.

  • It worked! BUT Even more confusing! Why does the button work, but there is no link (in Chrome)? so NO - <a href="" onclick="goBack() style ="text-decoration:none; color:#ffcc00; font:bold 14px '';"> & # 60 & # 60 BACK </a> so YES - <button onclick = "goBack ();"> Back </ button> - I_CaR
  • Because after clicking on the link, the link is followed. You can do this: <a href = "" onclick = "goBack (); return false;" style = "text-decoration: none; color: # ffcc00; font: bold 14px '';"> & # 60 & # 60 BACK </a> - Alex Kapustin

History.js