Fluoresce Posted November 11, 2009 Share Posted November 11, 2009 I need to redirect after a short delay of about ten seconds. I am going to use a meta refresh, thus: <head> <meta http-equiv="refresh" content="10; url=http://www.mysite.com"> </head> Are meta refreshes safe? In other words, are they compatible with all major browsers? Might it not work in some instances? Quote Link to comment Share on other sites More sharing options...
haku Posted November 12, 2009 Share Posted November 12, 2009 They may not work, and are frowned on upon search engines. A php refresh is a better bet. <?php header("Refresh: 10"); ?> Quote Link to comment Share on other sites More sharing options...
Fluoresce Posted November 12, 2009 Author Share Posted November 12, 2009 Thanks, Haku. Can you tell me, please, why the PHP refresh is a better bet? And is this exactly how I would do it? <?php header("refresh: 10; url=http://www.url.com"); ?> If so, does it matter at all where this code goes? Quote Link to comment Share on other sites More sharing options...
haku Posted November 12, 2009 Share Posted November 12, 2009 It has to go before any output to the browser, i.e. at the very top of your page (before any whitespace or anything). meta refreshes are frown on by search engines, and can be blocked by certain browsers. Quote Link to comment Share on other sites More sharing options...
Fluoresce Posted November 12, 2009 Author Share Posted November 12, 2009 Thanks, Haku. I've put the code right at the top of the document, even above the doctype. It seems to be working fine. I'm using it with the understanding that it's safer and more compatible than a meta refresh. Are you certain that it works in all major browsers? Does it even work in Opera when redirecting is disabled? Are there any drawbacks with it at all? I appreciate the help very much. Quote Link to comment Share on other sites More sharing options...
haku Posted November 12, 2009 Share Posted November 12, 2009 Honestly, I haven't used it in three or four years, and I wasn't testing on Opera at the time, and I may not have even tested in on all the browsers that I was using at that time, so I couldn't say for sure. It should be more stable/compatible, as it's server based rather than browser based, but you'll have to test it out to find out for sure. Let me know your findings. Quote Link to comment Share on other sites More sharing options...
Fluoresce Posted November 12, 2009 Author Share Posted November 12, 2009 Thanks for the replies, man. One last question for anyone who can answer - and it might be a stupid question at that . . . Can meta tags interfere with the PHP refresh code if they include the attribute http-equiv? From what I understand, this attribute sends a HTTP header, too. (As you can probably tell, I don't understand this aspect of Web development very much. ) Quote Link to comment Share on other sites More sharing options...
Fluoresce Posted November 12, 2009 Author Share Posted November 12, 2009 Actually, I have another question . . . When doing a PHP refresh, if the refresh is set to occur after 10 seconds, does this mean 10 seconds after the whole page has downloaded? Quote Link to comment Share on other sites More sharing options...
FaT3oYCG Posted November 17, 2009 Share Posted November 17, 2009 that probably depends on the browser too but it should do. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.