admin管理员组

文章数量:1278854

In my project I am using below Javascript code history.back(); for gooing back to previous page.(like back arrow on window). This function is working fine on IE and Firefox but not on google crome?

<input type="button" value="Go back" onclick="history.go(-1); return false" />

I get the error bellow

Confirm Form Resubmission

This web page requires data that you entered earlier in order to be properly displayed. You can send this data again, but by doing so you will repeat any action this page previously performed. Press Reload to resend that data and display this page.

Did googling but everybody is suggesting history.go(-1);return false; but it does not work either. Also tried history.back() but that does not help too

In my project I am using below Javascript code history.back(); for gooing back to previous page.(like back arrow on window). This function is working fine on IE and Firefox but not on google crome?

<input type="button" value="Go back" onclick="history.go(-1); return false" />

I get the error bellow

Confirm Form Resubmission

This web page requires data that you entered earlier in order to be properly displayed. You can send this data again, but by doing so you will repeat any action this page previously performed. Press Reload to resend that data and display this page.

Did googling but everybody is suggesting history.go(-1);return false; but it does not work either. Also tried history.back() but that does not help too

Share Improve this question edited Apr 18, 2015 at 13:08 php-dev 7,1564 gold badges26 silver badges38 bronze badges asked Jun 20, 2013 at 9:05 emillyemilly 10.5k36 gold badges110 silver badges183 bronze badges 1
  • may be html5 history api could help you out: history.pushState(null, null, link.href); – Karl Adler Commented Jun 20, 2013 at 9:25
Add a ment  | 

3 Answers 3

Reset to default 6

The previous page was displayed after a POST request (usually occurs when submitting a form). That means, to display the previous page, the form data, which was submitted in the POST request, must be submitted again. It has nothing to do with your history.go(-1) of Javascript, it will also occur when you press the back button of your browser.

You can use the Post Redirect Get pattern do work around this problem.

You can also use GET on your form instead:

<form action="..." method="GET">

However, do not use this for forms where data is added on your server, or it will be submitted everytime the user the back button and es back to this page. See also: When should I use GET or POST method?

Try this:

<script>
function goback() {
    history.go(-1);
}
</script>
<a href=”javascript:goback()”>Back</a>

It works in Chrome and other browsers.

The above was copied verbatim from:

http://simonthegeek./technical/history-back-problems-with-chrome-and-safari/

I would prefer client side code instead of harrasing my server
I tried this and it worked on all browsers:

<button onclick="javascript:window.history.back()">Back</button>  

EDIT
Alternately you can use web cache to store which was your last page and then you can easily redirect on that page..

本文标签: javascripthistorygo(1) does not work on chrome Any alternativeStack Overflow