How to work History.back() in IE8 and above Versions

六眼飞鱼酱① 提交于 2019-12-11 19:39:10

问题


I'm facing a big issue related to "Back Button", Currently I am using JavaScript back button like - parent.history.back(); but it is giving error like "Webpage has expired" on clicking Back button. is there any solution to get rid of it. My Project is in Asp.net.Every comment is appreciated. Thank you..!


回答1:


Here is a working example (tested on saucelabs IE7, IE8, IE9 @Windows XP and Vista)

<input type="button" id="push-me" value="Push me!" onclick="window.history.back(); return false;"/> 

If it still doesn't work for you may ensure that your tests are not executed within an iframe but a separate window.




回答2:


It is probably a syntax error.

onclick="history.go(); return false;" 

or

onclick="history.go(-1); return false;" 

should work. Else you could try document referrer instead:

location.href = document.referrer;


来源:https://stackoverflow.com/questions/20561152/how-to-work-history-back-in-ie8-and-above-versions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!