I was using this code to reload the page, however I'd only tested it on Chrome and when I tried it on Firefox I realized 开发者_StackOverflow中文版it didn't work. How do I make it work in other browsers?
echo 'Reloading. <META HTTP-EQUIV="refresh" CONTENT="0">';
Thanks
Instead of pushing out invalid HTML, instead, send the actual header using PHP's header
function.
header("Location: http://where.you/want/to/redirect.to");
If the page has already loaded (even partially), then this approach will not work -- in that case, either using JavaScript or the <meta>
tag will do the trick -- just remember that the <meta>
tag must be added to the <head>
portion of your HTML file.
<script type="text/javascript">window.location.reload(true);</script>
What you are doing is telling the browser to refresh. However, the <meta>
tag you are using is meant to be in the <head>
part of the document. That is probably why Firefox isn't properly executing it.
If you instead use the blurb above, which is javascript, you can put that code virtually anywhere in the document and it will cause the page to refresh.
My guess is that it's not working because it's not in the <head>
tag. Generate a properly formatted HTML document and it should work. But why in the world would you want to refresh the page after zero seconds?
精彩评论