window.history.go(-1)
I am using this JS function, it seems to be working perfectly in Chrome and Firefox but seems like it is not working in Safari... Does anybody know how to make it work in Safari?
window.history.go(-1)
I am using this JS function, it seems to be working perfectly in Chrome and Firefox but seems like it is not working in Safari... Does anybody know how to make it work in Safari?
You can try the following:
Check if you are actually making the call by adding an alert("history() called")
in place of the history(-1)
code;
Is it in a link that has a default behavour to navigate to another page? If so, you need a event.preventDefault()
or at least a return false;
after the history() call.
Edit: Andy mentioned this link: Is History API broken on iOS? (Location bar doesn't update on pushState) Maybe you can use that.
If you don't want to use event.preventDefault() method.Then
<script>
function gofunc() {
history.go(-1);
}
</script>
The call the function:
<a href="javascript:gofunc()">Nav Element</a>