[thelist] JavaScript Rollover explanation
kalyani deshpande
kalyanideshpande at yahoo.com
Thu Mar 8 10:18:44 CST 2001
> Hi all,
>
> I wanted to clarify rollovers with the JavaScript
> gurus on the list.
>
> If this is the code:
> ____________
> <!--
> if (document.images){
> img1on= new Image();
> img1on.src="image1on.gif";
> }
>
> function imgOn(imgName){
> if (document.images){
> document[imgName].src = eval(imgName + "on.src");}
> }
>
> -->
>
> <a href="http://someurl.com"
> onMouseOver="imgOn('img1')"
> onMouseOut="imgOff('img1')">
> <img name="img1" border=0 height=65 width=65
> src="image1off.gif"></a>
> ________
>
> the "if" statement checks to see whether the browser
> is capable of using the images. the code after that
> loads the images into memory so when the mouseovers
> occur, the "off" images are already downloaded and
> reduce the lag time between the rollover.
>
> the function defines what will take place. the
> "on.src" refers to any image with that extension, as
> does "off.src".
>
> in the last bit of code, the onMouseOver event
> handler
> calls the function.
>
> my questions for you -
>
> 1. am i getting this right?
> 2. what does eval() do?
> 3. why does the last line state the source as
> "image1off.src"? what does that mean? is that like a
> default because we actually start with the "off" and
> then go to "on" and then back to "off"
>
> your help will be much appreciated.
>
> thanks!
> kalyani
=====
__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail.
http://personal.mail.yahoo.com/
More information about the thelist
mailing list