简体   繁体   English

如何强制重新加载页面

[英]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 : 我需要在10秒后将页面重定向到另一个页面,并且要这样做,我正在使用php header:

header( "Refresh:10; url= http://myurl.local/test2.php ", true, 303); 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? 您是否在带有此标头的页面中使用OnBeforeUnload()javascript函数? 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/ 更多详细信息: 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: header()函数中的第二个参数是replace并且php.net提到:

The optional replace parameter indicates whether the header should replace a previous similar header, or add a second header of the same type. 可选的replace参数指示标头应替换先前的相似标头还是添加第二个相同类型的标头。 By default it will replace, but if you pass in FALSE as the second argument you can force multiple headers of the same type. 默认情况下,它将替换,但是如果您将FALSE作为第二个参数传递,则可以强制使用相同类型的多个标头。

So change the parameter to false may work for you 因此将参数更改为false可能对您有用

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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