HighDots Forums  

Re: swapping images (more than 1 instance)?

Javascript JavaScript language (comp.lang.javascript)


Discuss Re: swapping images (more than 1 instance)? in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Randy Webb
 
Posts: n/a

Default Re: swapping images (more than 1 instance)? - 01-30-2008 , 11:48 AM






Doug Gunnoe said the following on 1/30/2008 10:34 AM:

<snip>

Quote:
pic1 = new Image();
pic1.src = 'btn1.GIF';
pic2 = new Image();
pic2.src = 'btn2.GIF'
function swapImage(btnID){
if(document.getElementById(btnID).src == pic1.src)
document.getElementById(btnID).src = pic2.src;
else document.getElementById(btnID).src = pic1.src;
}
Be careful with that. The .src property of an image includes the full
URL to the file. Not just the filename itself.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/


Reply With Quote
  #2  
Old   
Doug Gunnoe
 
Posts: n/a

Default Re: swapping images (more than 1 instance)? - 01-30-2008 , 12:39 PM






On Jan 30, 10:48*am, Randy Webb <HikksNotAtH... (AT) aol (DOT) com> wrote:

Quote:
Be careful with that. The .src property of an image includes the full
URL to the file. Not just the filename itself.
Thanks. It's funny you should mention that. I did it that way because
the url was a long string of goop and I was being lazy.



Reply With Quote
Reply




Thread Tools
Display Modes

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



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.