Reputation: 9327
href="#" onclick="closeOrCancel()
and history.go(-1)
in that js method doesnt work in Chrome (neither history.back()
)
It works with href="javascript:closeOrCancel()"
, but Opera doesn't allow href="javascript:...
How to make history go back using onclick= "myFunction()" ?
Edit: closeOrCancel()
returns false
Upvotes: 8
Views: 28683
Reputation: 43243
You're wrong about two things here:
Please provide source for your script, since the problem is clearly in it and not the browsers.
Just put this in a html file and open it to see for yourself:
<script>
function goback() {
history.go(-1);
}
</script>
<a href="javascript:goback()">goback</a>
<a href="#ttttt">tt</a>
First click the "tt" link, then "goback". See the hash change. It works fine, although I'd personally recommend against using javascript in href's.
Upvotes: 1
Reputation: 16682
Adding a return false;
to the onclick
code seems to be enough:
<a href="#" onclick="closeOrCancel(); return false;">Go Back</a>
Upvotes: 14