SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Evangelist Alchemist's Avatar
    Join Date
    Aug 2006
    Posts
    412
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    changing onmouseout dynamically

    Hello everyone,

    I'm trying to change the onmouseout event of a div dynamically through javascript but it just doesn't work. any idea? thanks

    HTML
    HTML Code:
    <div id="volume-wrapper" onmouseout="">
    <div id="volume" onmouseover="SlideVolumeDown(); return false">
    </div>
    </div>
    JS

    Code:
    function SlideVolumeDown()	{
    
    document.getElementById("volume-wrapper").onmouseout.value = "SlideVolumeUp(); return false";
    
    }
    function SlideVolumeUp()	{
    document.getElementById("volume-wrapper").onmouseout.value = "";
    
    }

  2. #2
    SitePoint Addict
    Join Date
    Dec 2007
    Posts
    358
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You need to change the function, not the string:

    Code:
    function SlideVolumeDown()	{
    
    document.getElementById("volume-wrapper").onmouseout.value = function () { SlideVolumeUp(); return false; };
    
    }
    function SlideVolumeUp()	{
    document.getElementById("volume-wrapper").onmouseout.value = null;
    
    }
    I'm creating trouble-free Apache, PHP, MySQL installer, WITSuite,
    and use it to setup my development environment.
    Demo, support, contact. Questions?

  3. #3
    SitePoint Evangelist Alchemist's Avatar
    Join Date
    Aug 2006
    Posts
    412
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks for the tip. I tried that, but it still doesn't work. in IE, it throws an error....null or not an object

  4. #4
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    onmouseout doesn't have a value property, it contains a reference to a function instead.

    Clear it with:
    document.getElementById("volume-wrapper").onmouseout = '';
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  5. #5
    SitePoint Evangelist Alchemist's Avatar
    Join Date
    Aug 2006
    Posts
    412
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok. I changed the first function as well and it works now

    Code:
    function SlideVolumeDown()	{
    
    document.getElementById("volume-wrapper").onmouseout = function () { SlideVolumeUp(); return false; };
    
    }


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •