lisovaccaro
lisovaccaro

Reputation: 33956

Multibrowser refresh/reload page

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 it didn't work. How do I make it work in other browsers?

echo 'Reloading. <META HTTP-EQUIV="refresh" CONTENT="0">';

Thanks

Upvotes: 0

Views: 153

Answers (3)

Sean Vieira
Sean Vieira

Reputation: 159955

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.

Upvotes: 2

Jonah
Jonah

Reputation: 10091

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?

Upvotes: 1

Tyler Carter
Tyler Carter

Reputation: 61567

<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.

Upvotes: 1

Related Questions