Reply
Can this be done in Javascript?
Old 12-21-2004, 08:55 PM Can this be done in Javascript?
Junior Talker

Posts: 3
Location: So Cal
I have an image hosted online that I want to display on a web page, but if the server the image is hosted on is down, then I want a different image (hosted on a different server) to appear in its place.

Can this be done with Javascript, maybe using the if statement? If yes, then how?

I know html and can do all the img tags, but I only know a little Javascript.
Thanks
jasekasp is offline
Reply With Quote
View Public Profile Visit jasekasp's homepage!
 
When You Register, These Ads Go Away!
Old 12-22-2004, 06:18 AM
sdcdesign.co.uk's Avatar
Extreme Talker

Posts: 199
Location: High Wycombe, Buckinghamshire, London
Hi,

To my knowledge so far, i've never come across a way to detect if a server is down in javascript. A colleague of mine did it once but it was extensive asp.net using Tcp.IP protocols!


So, i think the answer is no, your better off trying to see if there is a pre-made script in php or asp.net or something along those lines.

However, i might be completely mistaken!

Good Luck,


Sean
__________________
[ Insert witty, yet highly intelligent signature here ]
sdcdesign.co.uk is offline
Reply With Quote
View Public Profile Visit sdcdesign.co.uk's homepage!
 
Old 12-23-2004, 02:56 PM
Rufo's Avatar
Extreme Talker

Posts: 173
You could probably use a hidden IMG tag, which has its SRC attribute set to the remote image.
Javascript could then be used to check whether the IMG's onLoad event was fired within a certain period of time (eg. 3 seconds).
If it had not loaded, you could assume that the server was down, and set the SRC attribute to an alternate image using javascript.

Rufo.
__________________
mp3blog.us
Rufo is offline
Reply With Quote
View Public Profile Visit Rufo's homepage!
 
Reply     « Reply to Can this be done in Javascript?
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.12465 seconds with 12 queries