Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 10-28-2003, 01:04 PM   PM User | #1
Xylitol
New to the CF scene

 
Join Date: Oct 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Xylitol is an unknown quantity at this point
On event not available do this

I would like help on how to do the following in JS.

On load get image.gif from http://abc.com
If image.gif from http://abc.com is not available
Then goto http://xyz.com and get image.gif

What I'm trying to do is have my online presence known http://abc.com is my webserver @ home
http://xyz.com is a hosted server @ yahoo

I am sorry if I may not be sticking to the guidelines, This just seemed the best way to explain.

Thank you
Xylitol is offline   Reply With Quote
Old 10-28-2003, 01:16 PM   PM User | #2
Caffeine
Regular Coder

 
Join Date: Mar 2003
Posts: 241
Thanks: 0
Thanked 0 Times in 0 Posts
Caffeine is an unknown quantity at this point
Halu and welcome aboard!

Yes, there is a solution to your problem, in fact I think your description was very well put.



Take a look at this code, written by Danne [or choose Spookster's version if you find it more attractive] in this thread

Code:
<script type="text/javascript">
function setImg(newImg){
    var obj=document.getElementById("dynImg");
    obj.src=newImg;
}

</script>
<body onLoad="setImg('example01.jpg');">
...
<img id="dynImg" onError="this.src='noimageavail.jpg';">
Hope that helps,
Caffeine is offline   Reply With Quote
Old 10-28-2003, 01:32 PM   PM User | #3
Xylitol
New to the CF scene

 
Join Date: Oct 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Xylitol is an unknown quantity at this point
Thank you . Looking at the code it looks like it may do the job .
will look at Spookster's version too.

Xylitol is offline   Reply With Quote
Old 10-28-2003, 01:35 PM   PM User | #4
Caffeine
Regular Coder

 
Join Date: Mar 2003
Posts: 241
Thanks: 0
Thanked 0 Times in 0 Posts
Caffeine is an unknown quantity at this point
It's just beneath Danne's in the link I posted.

Personally I would have used Spookster's version as it does not mess with the onload-event. IMO it's a good practice to avoid doing so unless you really have to.
Caffeine is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:41 AM.


Advertisement
Log in to turn off these ads.