corsasport.co.uk
 

Corsa Sport » Message Board » Off Day » Geek Day » HTML redirect


New Topic

New Poll
  Subscribe | Add to Favourites

You are not logged in and may not post or reply to messages. Please log in or create a new account or mail us about fixing an existing one - register@corsasport.co.uk

There are also many more features available when you are logged in such as private messages, buddy list, location services, post search and more.


Author HTML redirect
Steve
Premium Member

Avatar

Registered: 30th Mar 02
Location: Worcestershire Drives: Defender
User status: Offline
12th Jul 12 at 13:30   View Garage View User's Profile U2U Member Reply With Quote

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
12th Jul 12 at 13:54   View User's Profile U2U Member Reply With Quote

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
12th Jul 12 at 13:56   View User's Profile U2U Member Reply With Quote

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
12th Jul 12 at 14:12   View User's Profile U2U Member Reply With Quote

Oh, if its just a browser refresh, I use an addon for firefox.

http://www.grizzlyape.com/addons/auto-refresh/
Steve
Premium Member

Avatar

Registered: 30th Mar 02
Location: Worcestershire Drives: Defender
User status: Offline
12th Jul 12 at 14:22   View Garage View User's Profile U2U Member Reply With Quote

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
12th Jul 12 at 14:25   View User's Profile U2U Member Reply With Quote

<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
12th Jul 12 at 14:33   View User's Profile U2U Member Reply With Quote

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
12th Jul 12 at 15:05   View User's Profile U2U Member Reply With Quote

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
12th Jul 12 at 15:08   View User's Profile U2U Member Reply With Quote

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
12th Jul 12 at 15:15   View User's Profile U2U Member Reply With Quote

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
12th Jul 12 at 15:24   View User's Profile U2U Member Reply With Quote

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

Avatar

Registered: 30th Mar 02
Location: Worcestershire Drives: Defender
User status: Offline
12th Jul 12 at 15:37   View Garage View User's Profile U2U Member Reply With Quote

Sorted bliss

 
New Topic

New Poll

  Related Threads Author Forum Replies Views Last Post
.htaccess folk - need help Dom Geek Day 7 616
21st Jun 06 at 23:37
by Dom
 
URL Forwarder code? Cosmo Geek Day 4 380
20th Mar 07 at 12:50
by Cosmo
 
Flash/Actionscript/Macromedia Peeps Dom Geek Day 5 246
7th Jun 07 at 16:46
by Dom
 
Domain redirect Cosmo Geek Day 4 272
7th Jun 08 at 13:24
by Cosmo
 
(WinServ 2003) internal DNS Redirect Dom Geek Day 4 193
13th Aug 08 at 10:42
by pow
 

Corsa Sport » Message Board » Off Day » Geek Day » HTML redirect 28 database queries in 0.0146279 seconds