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 8038119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T03:07:52+00:00 2026-06-05T03:07:52+00:00

I know this isn’t supposed to be inline, but YUI library’s dialogs force me

  • 0

I know this isn’t supposed to be inline, but YUI library’s dialogs force me to. My issue is that whenever I hover over this div, the margin-left scroll activated but it does not stop when I move the mouse out of the div. The JS console reports that:

Uncaught ReferenceError: timerID is not defined

And here’s the code:

<div class="span1" onmouseover="
            var timerID;
             $(document).ready(function(){              
                    timerID = setInterval(scrollLeft, 10);

                    function scrollLeft(){
                        $('.inner_wrapper').animate({
                            marginLeft: '-=30px'
                        });
                    }
             });
             " onmouseout="clearInterval(timerID)">
        </div>

EDIT: The thing is that I can NOT run SCRIPT tags inside dialogs (they are already created via scripts, which filter any javascript besides inline one like onmouseover and onmouseout). So your suggestions of encapsulating the onmouseover and onmouseout handles in a single function will not work in this case.

  • 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-05T03:07:53+00:00Added an answer on June 5, 2026 at 3:07 am

    It’s a scope problem. You variable timerID is not visible in onmouseout.

    Generally it is a good idea, to put stuff into a function instead of clobbering it all into the attributes. This avoids all these scope-problems. And it’s an even better idea to use handlers instead of the on-...-atrributes.

    Define your function outside the onmouseover attribute and call another function in the mouseout which clears it.

    Something like this (to avoid nasty global varaibles)

    var handler = (function(){
        var timerID;
        function scrollLeft(){
           $('.inner_wrapper').animate({
               marginLeft: '-=30px'
           });
        }
        return{
          mouseover:function(){              
                timerID = setInterval(scrollLeft, 10);
             },
          mouseout:function(){
                clearInterval(timerID);
          }
        }
    })();
    

    and then

    <div class="span1" onmouseover="handler.mouseover()" onmouseout="handler.mouseout()">
    

    or even better, bind the handlers directly via:

    $('.span1').hover(function() {
        timerID  = setInterval(scrollLeft, 10); //mouseover
    }, function() {
        clearInterval(timerID); //mouseout
    });
    

    As of new jQuery 1.7, .on()should be preferred.

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

Sidebar

Related Questions

I know that C++11 provides <atomic> , but this isn't implemented by any compiler
I know this isn't really how <button> elements are supposed to be used, but
I know this isn't a hard trig issue, but sadly I am math retarded.
I know this isn't a unique issue but I've not had much luck finding
I know this isn't recommended, but I do have folders with multiple projects that
I know this isn't best practice, but can I include all of the dependencies
I know this isn't so complicated but I can't remember how to do. I
I know this isn't right, but for the sake of illustration I'd like to
I know this isn't directly related to programming, but I was wondering if anyone
I know this isn't a programming question but I would really like the users

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.