Monday, May 20, 2024
56
rated 0 times [  63] [ 7]  / answers: 1 / hits: 48574  / 12 Years ago, mon, february 11, 2013, 12:00:00

Everybody knows that but I'll repeat the problem:



<a href=# onClick=history.go(-1)>Back</a>


Will not work in WebKit based browsers (Chrome, Safari, Mxthon, etc.)



Another approach (should work) that won't work is:



<a href=# onclick=javascript:window.history.back(-1);>Back</a>


You could do this - works! (but that's showing JS in url hint)



<a href=javascript:window.history.back(-1);>Back</a>


To use JS in onclick event you could do this (works, but see comments below):



<a onclick=javascript:window.history.back(-1);>Please try again</a>


Missing href will make it work, but then it won't appear as clickable link, you could apply css to make it look like link, apply blue color, underline and cursor hand, but who wants that?


More From » google-chrome

 Answers
9

Finally working solution, tested in IE, FF, Safari, Chrome, Opera, Maxthon:



<a href=# onclick=window.history.back();return false;>Back</a>


Don't forget semicolon after return false;


[#80290] Sunday, February 10, 2013, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
loganl

Total Points: 424
Total Questions: 86
Total Answers: 112

Location: Zimbabwe
Member since Thu, Jul 21, 2022
2 Years ago
;