开发者

browser backbtn with javascript

I am creating a quiz game in PHP. I maintain a session from the start to the end of the quiz. When the user clicks on the back button in the middle of the quiz It display a page wit开发者_C百科h message

"Confirm Form Resubmission This web page requires data that you entered earlier in order to be properly displayed"

So, I m trying to keep it on the same page on click of back button

I have handled the "onbeforeunload" event & it's firing up too.

code snippet

Redirectpage { javascript:window.history.forward(1); }

but still am getting the same error?

thankyou folks.


Your page does not have rights to control the browser. OnbeforeUnload you can alert user and return false to stay on the page. Otherwise you cannot do much on it except expiring the previous page, so that user cannot go to previous page.


Two possible solutions:

Don't use use post, that's what causes the warning, if you submit using get, you won't get the warning.

If you can't do that:

Use AJAX instead of posting and replacing the entire page. That is so 1990s and leads to very confusing code. Keep state on the client. It doesn't seem you have a need to bookmark each of the pages, and if you did, you'd have to learn how to handle back button within an AJAX app. Here's one solution: http://www.zedwood.com/article/101/ajax-back-button-fix

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜