简体   繁体   中英

How to force reload a page

I need to redirect a page to another after 10seconds, and to do that, i'm using php header :

header( "Refresh:10; url= http://myurl.local/test2.php ", true, 303);

But the problem is that when page go to be redirect, a browser dialog box ask for a confirmation (this page ask to confirm the close, some data can be lost ....) and finally don't redirect.

My question is : how can I discard automatically this ?

Warmest thanks !

Are you using OnBeforeUnload() javascript function in the page with this header? Might help if you would remove that call.

More details: https://www.404techsupport.com/2010/03/ask-404ts-whats-up-with-are-you-sure-you-want-to-navigate-away-from-this-page-dialogs/

Second parameter in the header() function is replace and php.net mentions that:

The optional replace parameter indicates whether the header should replace a previous similar header, or add a second header of the same type. By default it will replace, but if you pass in FALSE as the second argument you can force multiple headers of the same type.

So change the parameter to false may work for you

header( "Refresh:10; url=http://myurl.local/test2.php", false, 303);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM