Results 1 to 4 of 4

Thread: mouseover buttons disappear

  1. #1
    Join Date
    Jul 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default mouseover buttons disappear

    I am using the floating menu script at http://www.dynamicdrive.com/dynamici...staticmenu.htm
    on a web site at http://www.reflectiontime.com

    Some of the buttons will disappear when clicking on them and sometimes the mouseover effect does not work. I have some other java links on same page, and am wondering if there is a conflict with running more than one script.
    The floating effect works nicely though.
    Thanks for any help on this.
    JJ

  2. #2
    Join Date
    Jul 2005
    Location
    Kuwait-I'm American
    Posts
    127
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Must be your browser. They work fine on mine.
    //\\ //\\// || //\\//\\ //\\ ||_
    SOFTWARE

  3. #3
    Join Date
    Jul 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I tried viewing the site on a different computer that had high speed internet, and it did once or twice on it, and my customer says it happens quite frequently on her computer, and she live in a different country.
    Any clues?

  4. #4
    Join Date
    Jul 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I got it. Thanks shyam at the Coding Forums. JJ~


    i think thats because the body.onload will be called long after the other inline javascript functons calls have been executed. so, if the mouse was already over an image while rollover is being called causes that images source to become undefined.

    you can fix this by making imgOrSrc an attribute of the image itself and setting it before the event handler.


    Code:
    function rollover() {
    if (!document.getElementById) return
    var imgOrSrc;
    var imgPreload = new Array();
    var images = document.getElementsByTagName('img');
    for (var i = 0; i < images.length; i++) {
    if (images[i].getAttribute('rsrc')) {
    imgPreload[i] = new Image();
    imgPreload[i].src = images[i].getAttribute('rsrc');
    images[i].imgOrSrc = images[i].getAttribute("src");
    images[i].onmouseover = function() {
    this.imgOrSrc = this.getAttribute('src');
    this.setAttribute('src',this.getAttribute('rsrc'))
    }
    images[i].onmouseout = function() {
    this.setAttribute('src',this.imgOrSrc)
    }
    }
    }
    }

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
  •