webkit / Chrome history.back(-1) onclick vs href

冷暖自知 提交于 2019-11-30 17:13:50
Pawel Cioch

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;

Viishnuu

It works even history.go(-1) also...

For Chrome, IE, Mozilla i tested, works fine. use below code:

<a href="#" onclick="history.go(-1);return false;" style="text-decoration:underline;">Back</a>

This is the only thing that works on all current browsers:

<script>
function goBack() {
    history.go(-1);
}
</script>
<a onclick="goBack()">Back</a>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!