Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8592415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:44:45+00:00 2026-06-11T23:44:45+00:00

this script is doing a roll over on images on each mouse event e.g.

  • 0

this script is doing a “roll over” on images
on each mouse event e.g. mousover out and click

img src is changed,
the problem is i was trying to delay
the execution of the function
executed by onClick event .

i tried to change function to settimeout but with no success

setTimeOut('functionName(param1, param2)', 5000);

nither calling a function that encapsulate the set time out

what am i doing wrong ?

       <a href="yourpage.htm">
    <img src="images/Button2_Normal.PNG" width="150" id="img2" 
onmouseover="mOver(this, image2)" onmouseout="mOut(this, image2)" onclick="mActive(this, image2)" />
                    </a> 

                    <a href="yourpage.htm">
          <img src="images/Button1_Normal.PNG"  width="150" id="img1" 
       onmouseover="mOver(this, image1)" onmouseout="mOut(this, image1)" onclick="mActive(this, image1)">
</a>
  • javascript

    var image1 = new Array("images/Button1_Normal.PNG", "images/Button1_MouseClick.PNG", "images/Button1_MouseOver.PNG");
    var image2 = new Array("images/Button2_Normal.PNG", "images/Button2_MouseClick.PNG", "images/Button2_MouseOver.PNG");
    
    var preloadImages = new Array();  // preloads images
    function Loadimages(images) {
    
        for (i = 0; i < images.length; i++) {
            preloadImages[i] = new Image()
            preloadImages[i].src = images[i]
        }
    }
    Loadimages(image1);
    
    
    lastN = ""
    
    function mOver(obj, images) {
        if (lastN != obj.id) {
            document.images[obj.id].src = (images.length == 3 ? images[2] : images[1])
        }
    }
    
    function mOut(obj, images) {
        if (lastN != obj.id) {
            document.images[obj.id].src = images[0]
        }
    }
    
    function mActive(obj, images) {
        var ts1 = document.getElementById('img1');
        if (typeof obj != "string") { obj = obj.id }
    
        document.images[obj].src = images[1]
        if (lastN != "" && lastN != obj) {
            document.images[lastN].src = images[0]
        }
        lastN = obj
    }
    function timeout_init(obj,images) {
        setTimeout('mActive(obj, images)', 5500);
    }
    
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T23:44:46+00:00Added an answer on June 11, 2026 at 11:44 pm

    Closure should work:

    function timeout_init(obj,images) {
      setTimeout(function() {
        mActive(obj, images);
      }, 5500);
    }
    

    It’s another reason to avoid eval-like functionality. With your current implementation JavaScript engine will take “'mActive(obj, images)'” string and try to eval()uate it in global context. By that time the original obj and images variables are long lost.

    With closure your anonymous function will still have access to timeout_init() argument, despite that function finished. But variables survived as they were referenced by inner function.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need a little help getting this script doing what I want it to.
This is the way I am currently doing it. <?php //show footer echo <script
This script works fine on single click but on double click it shows both
So I have this Div that has a roll over effect on it where
I wanted to get this question out there to see if I'm doing this
i know nothing about ruby, can anyone help explaining what this script is doing
Alrighty so below I have this script doing exactly what I want; I'm using
What am I doing wrong I have this script, and added the $randnumber =
Found this script: function stopRKey(evt) { var evt = (evt) ? evt : ((event)
I have this script:- SELECT TOP 1 column_01, COUNT(column_01) OVER(), (SELECT TOP 1 COUNT(column_02)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.