HighDots Forums  

Image roll-over problem

alt.html.dhtml alt.html.dhtml


Discuss Image roll-over problem in the alt.html.dhtml forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Aaron Russell
 
Posts: n/a

Default Image roll-over problem - 07-07-2003 , 05:59 AM






Hi

I am somewhat a novice at this and I am encountering a problem which I hope
someone might be able to help me with. I am using a javascript image roll
over which is supposed to prelode the images. However, when I move my mouse
over the image it takes a second or so for the new image to download before
it displays - ie it is NOT preloading the image. Here is the script:

if (document.images){
buttonOn=new Image();
buttonOn.src="on.gif";
buttonOff=new Image();
buttonOff.src="off.gif";}

function imgOn(imgName){
if (document.images) {
document[imgName].src = eval(imgName + "On.src");}}

function imgOff(imgName){
if (document.images) {
document[imgName].src = eval(imgName + "Off.src");}}

<a href="link.htm" onMouseOver="imgOn('button');"
onMouseOut="imgOff('button');">
<img name="button" src="off.gif"></a>

Can anyone explain why the images are not preloading or provide a script
which will definitly work? Your help is much appreciated.

Thanks

Aaron



Reply With Quote
  #2  
Old   
Wayne
 
Posts: n/a

Default Re: Image roll-over problem - 07-08-2003 , 08:44 AM






"document.getElementsByTagName("IMG")[name].src"
can be replaced with
"document.getElementsById(name).src"

--

Wayne



Reply With Quote
  #3  
Old   
Wayne
 
Posts: n/a

Default Re: Image roll-over problem - 07-08-2003 , 01:12 PM



"Wayne" <wayne_dobson (AT) hotmail (DOT) com> wrote

Quote:
"document.getElementsByTagName("IMG")[name].src"
can be replaced with
"document.getElementsById(name).src"
Whoops!

That should be: document.getElementById(name).src

--

Wayne




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.