Steve
Premium Member
Registered: 30th Mar 02
Location: Worcestershire Drives: Defender
User status: Offline
|
How do i refresh a webpage and keep it refreshing say every 2 seconds until the page i want to redirect to is available
eg a local HTML page that tries to redirect to another and if it cant make it eg due to network cable being unplugged, just refreshes itself over and over then as soon as i plug the LAN cable on its next refresh it redirects to another page elsewhere that becomes available?
must be html or javascript
[Edited on 12-07-2012 by Steve]
|
Whittie
Member
Registered: 11th Aug 06
Location: North Wales Drives: BMW, Corsa & Fiat
User status: Offline
|
What do you mean exactly? Custom 404 page or a temorary refirect? Don't get what you mean when you're on about the network being unplugged, it obiviously won't load?
|
John
Member
Registered: 30th Jun 03
User status: Offline
|
Firefox or opera have a timed refresh option I think.
|
Whittie
Member
Registered: 11th Aug 06
Location: North Wales Drives: BMW, Corsa & Fiat
User status: Offline
|
Oh, if its just a browser refresh, I use an addon for firefox.
http://www.grizzlyape.com/addons/auto-refresh/
|
Steve
Premium Member
Registered: 30th Mar 02
Location: Worcestershire Drives: Defender
User status: Offline
|
I want IE to load a local html document that tries to redirect to another webpage, and if it fails, due to lack of network connectivity instead of showing a 404, it just refreshes itself until the page becomes available.
i think some sort of javascript check if a file exists on the server elsewhere might sort
|
Whittie
Member
Registered: 11th Aug 06
Location: North Wales Drives: BMW, Corsa & Fiat
User status: Offline
|
<META HTTP-EQUIV="refresh" CONTENT="60">
60 being the seconds.
Not sure how it'll cope with the network cable out there, guessing it just won't load and display that you're not connected to tinternets.
Edit: to redirect to another url....
<meta http-equiv="refresh" content="60;URL='http://example.com/'">
[Edited on 12-07-2012 by Whittie]
|
ed
Member
Registered: 10th Sep 03
User status: Offline
|
You need to poll the page you're looking for using an AJAX request and look at the response code you're returned. 404 = no good, 200 = go for it. You can then trigger the redirect.
|
Dom
Member
Registered: 13th Sep 03
User status: Offline
|
Whittie - What you posted wouldn't work because as soon as the timeout is reached it'll redirect to the external address (which could possibly 404) and wouldn't continue to refresh.
quote: Originally posted by ed
You need to poll the page you're looking for using an AJAX request and look at the response code you're returned. 404 = no good, 200 = go for it. You can then trigger the redirect.
What this man said. Do a google for 'Ajax Header Status' and you'll get plenty of results, like StackOverflow.
|
Whittie
Member
Registered: 11th Aug 06
Location: North Wales Drives: BMW, Corsa & Fiat
User status: Offline
|
quote: Originally posted by Dom
Whittie - What you posted wouldn't work because as soon as the timeout is reached it'll redirect to the external address (which could possibly 404) and wouldn't continue to refresh.
quote: Originally posted by ed
You need to poll the page you're looking for using an AJAX request and look at the response code you're returned. 404 = no good, 200 = go for it. You can then trigger the redirect.
What this man said. Do a google for 'Ajax Header Status' and you'll get plenty of results, like StackOverflow.
Thought so, but that was the only html (as he requested) that I knew that would do it
|
Dom
Member
Registered: 13th Sep 03
User status: Offline
|
Could also do it entirely using JS using the xmlhttprequest object, then just send a request and check the status. Saves the overheads of having to call in the JQuery library, although AJax'ing it would personally be easier to do.
[Edited on 12-07-2012 by Dom]
|
ed
Member
Registered: 10th Sep 03
User status: Offline
|
You'd probably have to use the full ajax request with jQuery anyway so you'd be writing just about the same amount of code as XMLHttpRequest.
|
Steve
Premium Member
Registered: 30th Mar 02
Location: Worcestershire Drives: Defender
User status: Offline
|
Sorted bliss
|