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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mouseOver turnoff after a number of seconds

Status
Not open for further replies.

mcvdmvs

Technical User
Sep 18, 2000
172
NL
Ok, i have a little problem, i wanna change my mouseOver image after 2 seconds. But i cant get it right, i tried this:

function turnOn(imageName)
{
if (document.images)
{
document.images[imageName].src = eval (imageName + 'on.src');
setTimeout("document.images[imageName].src = eval (imageName + 'off.src');",2000)
}
}
What am i doing wrong?
 
You need to use:
Code:
function turnOn(imageName)
{
  if(document.images) {
    document.images[imageName].src = eval(imageName + 'on.src');
    setTimeout("document.images['" + imageName + "'].src = eval('" + imageName + "' + 'off.src');",2000)
  }
}
Homework: Answer - why this will work, but your variant wasn't? :) [sig]<p>Michael Dubner<br>Brainbench MVP/HTML+JavaScript<br>
[/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top