0

I need to disable "redirecting after form post warning" dialog.
Which is same issue with:
Reload browser window after POST without prompting user to resend POST data

But in my case, I submit form from a colorbox dialog. After submiting form, I close the colorbox popup and reload the parent page:

 parent.location.reload();

But this gives that warning. How can I disable this?

Edit: Apperantely I get repost form warning in Internet Explorer. I don't get it from other browsers.

Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; .NET4.0C; InfoPath.2)
Community
  • 1
  • 1
trante
  • 33,518
  • 47
  • 192
  • 272
  • 1
    This link may be helpful. http://stackoverflow.com/questions/570015/how-do-i-reload-a-page-without-a-postdata-warning-in-javascript Or this one http://stackoverflow.com/questions/4869721/reload-browser-window-after-post-without-prompting-user-to-resend-post-data – FajitaNachos Sep 08 '12 at 07:27

1 Answers1

1
parent.location.href = parent.location.href;
Jorge Fuentes González
  • 11,568
  • 4
  • 44
  • 64
  • Logical. But I still got this problem in MSIE 8.0 and MSIE 9.0. – trante Sep 09 '12 at 10:05
  • If you want to reload the top page, try `window.top.location.href` instead. And, if you are using PHP, do it serverside, I mean, do `header("Location: http://example.com/");` it's better than javascript. – Jorge Fuentes González Sep 09 '12 at 10:25
  • Thank you for PHP tip, I will think of it.. For js side, you mean this one? window.top.location.href = window.top.location.href; – trante Sep 09 '12 at 15:00
  • Yes, but keep in mind that that code will reload the main page, so if the parent page that you want to realod is inside a frame (iframe or something), it won't reload, it must be the main page. by the way, I tell you again, if you can modify the source code, use php's location, because not all browsers have javascript enabled and some other browsers will block it, but if you use headers, all browsers supports it and cannot be blocked the same way as javascript, will be 99.9% effective compared with javascript. – Jorge Fuentes González Sep 09 '12 at 21:26
  • It seems like not possible within PHP code. Because I submit form with an AJAX request and I check for the response of the AJAX. it request is successfull I redirect from success of javascript code. – trante Sep 15 '12 at 08:44
  • Ok, yes, it's impossible using headers this way. Try this: `var urlref=parent.location.href; parent.location.href=urlref;`. And before trying this, I forgot to tell you, remember to clear IE cache, it's possible that IE is not using the new javascript code although you updated it and pressed F5. If you want, instead of clearing cache, add this after the web where the javascript resides `?cache=1` (Has to be this way `http://example.com/example.html?cache=1`) and each time you modify it, change the number, so IE users will download a new one each time. – Jorge Fuentes González Sep 15 '12 at 11:05
  • @JorgeHmm thank you very much for help. Should I append that code snippet into the DOM after a successful AJAX response? – trante Sep 16 '12 at 11:17
  • No no, after a successful AJAX response you must reload modifying `parent.location.href`. Where do you have the reload code? (`parent.location.href`) in an external .js file or inside the main page between `` tags? So I can help you better with the cache trick. – Jorge Fuentes González Sep 17 '12 at 11:46
  • Sorry but I didn't understand. Do you recommend me to make this, if AJAX reuqest is successfull? `parent.location.href=parent.location.href+'?redirected;` – trante Sep 17 '12 at 14:18
  • No no. The cache trick is to force IE to download the new code. If you enter you web with IE after you modified your web code, IE don't uses it, IE just remebers your last code and don't downloads the new one, so you have to clear IE cache or force it to download the new code. So, if you changed your `parent.location.reload();` to `parent.location.href=parent.location.href;`, is possible that IE is still using `parent.location.reload();`, that's because you still get the same warning (maybe). Try to clear your cache first and then check if IE shows the same warning. – Jorge Fuentes González Sep 17 '12 at 16:06
  • If you don't know what cache is and how it works, read this: http://bit.ly/10vNTQ it's essential to know this before coding web pages. – Jorge Fuentes González Sep 17 '12 at 16:07