Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HELP!!! Preloaded images for rollovers will not work. 2

Status
Not open for further replies.

ID10T16

Technical User
Sep 22, 2000
160
US
Here is my code:
<html>
<head>
<script>
var button1= new Image();
button1.src=&quot;AdminButton1.gif&quot;;
var button2=new Image();
button2.src=&quot;AdminButton1.gif&quot;;
</script>

</head>

<a href=&quot;#&quot; onMouseOver=&quot;document.images[button2].src=button2.src&quot;

onMouseOut=&quot;document.images[button1].src=button1.src&quot;
><img src=&quot;AdminButton1.gif&quot;/></a>
</body>
</html>



When i start the page, I get the error message:
Line: 12
Char: 1
Error: 'document.images[...]'is null or not an object.
Code: 0

I don't know what's going on, but I need this to be working really soon. Thanx in advance for all your help.
 
That's because you didn't name your button.
Code:
<a href=&quot;#&quot; onMouseover=&quot;document.images.button.src=button2.src;&quot; onMouseout=&quot;document.images.button.src=button1.src;&quot;>
<img src=&quot;AdminButton1.gif&quot; name=&quot;button&quot;></a>
Sincerely,

Tom Anderson
CEO, Order amid Chaos, Inc.
 
This works in IE 4 and 5 and N... 4.06 on NT 4 Workstation

var g_images = new Array();
g_images[0] = new Image();
g_images[0].src = &quot;/images/amazon.jpg&quot;;
g_images[1] = new Image();
g_images[1].src = &quot;/images/msdnlogo.jpg&quot;;

function imgRotate(nIndex){

// make sure the resource is finished downloading before
// trying to use it!
if ( g_images[1].complete)
document.images[0].src = g_images[nIndex].src;
}

//-->
</SCRIPT>
</HEAD>
<BODY>

Rollovers<br>
<a href=&quot;#&quot;
onmouseover=&quot;imgRotate(1)&quot;
onmouseout=&quot;imgRotate(0)&quot;><img src=&quot;/images/amazon.jpg&quot;></a>


Hope this helps
-pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top