Skip to content Skip to sidebar Skip to footer

Using Javascript History.back() Fails In Safari .. How Do I Make It Cross-browser?

I am using Back to provide a back to previous page link. It works fine on Windows (IE/Mozilla) but fail

Solution 1:

it should be history.go(-1); return false; or history.go(-1); event.preventDefault();

Solution 2:

You should consider doing it like this instead:

<ahref="javascript:history.go(-1)">Back</a>

Solution 3:

Try this instead. It should work across IE, FF, Safari and Chrome.

<ahref="#"onclick="if(document.referrer) {window.open(document.referrer,'_self');} else {history.go(-1);} return false;">Cancel<a>

Solution 4:

The below code is working.

<ahref="javascript:void(0);"onclick="javascript:history.go(-1);">Back</a>

Solution 5:

If anyone is still struggling with this issue try removing the href-attribute from the link you want to use window.history.back() with. I'm not sure if this workaround complies with HTML-standards but it worked out fine for me.

Post a Comment for "Using Javascript History.back() Fails In Safari .. How Do I Make It Cross-browser?"