Possible Duplicate:
Quit function on body onLoad
I want to refresh my page if the page load time is more than 10 seconds. The solution can be in PHP or JavaScript/jQuery. How can I do that?
<meta http-equiv="refresh" content="0">
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The
<meta http-equiv="refresh" content="10">will reload the page once every 10 seconds (the first being 10 seconds after the page has loaded).This will however not be accessed until after the page has loaded.
In terms of PHP, you could see if the PHP script was taking more than 10 seconds to execute (by using a snippet at the start and end of your code to capture the timestamp), but not if the executed output was taking more than 10 seconds to load for the user.
There isn’t much you can do to see if the user has a slow connection at all.
[Edit:] You could set a timestamp right at the start of your code and echo it out to the user and have some javascript check to see if it was more than 10 seconds after the request had been initialized, but this could start to get problematic as the user may or may not have JS enabled; then you go into potentialy checking timezones, etc. This whole edit is starting to quickly become ‘yicky’ real quick, but this is another avenue you could consider, so I thought I’d add it.