Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Jun 2003
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Works in IE and Mozilla but not in NS, why?

    Can you tell me why the following works in IE, Mozilla and Opera but not in NS? I don't care about NS4, I just need it to work in NS6+
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Mouse Over</title>
    <script language="JavaScript" type="text/javascript">
    function domouseover(e) {
    e = (e) ? e : (window.event) ? window.event : ""
    if (e) {
    var elem = (e.target) ? e.target : e.srcElement
    if (elem.className == "test" ) {
    y=elem.id+'r';
    document.getElementById(y).style.color = 'red';
    }
    }
    }
    function domouseout(e) {
    e = (e) ? e : (window.event) ? window.event : ""
    if (e) {
    var elem = (e.target) ? e.target : e.srcElement
    if (elem.className == "test" ) {
    y=elem.id+'r';
    document.getElementById(y).style.color = 'black';
    }
    }
    }
    document.onmouseover=domouseover;
    document.onmouseout=domouseout;
    </script>
    </head>
    <body>
    <div id="x1r">
    This should become red when you mouse over the link, but it doesn't in Netscape.
    </div>
    <a href="#" id="x1" class="test">Mouse over me</a>
    </body>
    </html>

  • #2
    Regular Coder
    Join Date
    Sep 2002
    Location
    Surrey, UK
    Posts
    119
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Guessing now, because i can't test till later, but maybe:
    var elem = (e.target) ? e.target : e.srcElement
    might be the problem for NS6(inconsistencies between the Mozilla versions were a problem)
    Try:
    var elem = (e.target) ? e.currentTarget : e.srcElement
    for nS6 and branch if that helped.

  • #3
    New to the CF scene
    Join Date
    Jun 2003
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    just changing the line of
    var elem = (e.target) ? e.target : e.srcElement
    to
    var elem = (e.target) ? e.currentTarget : e.srcElement
    in the two functions didn't help
    Actually it doesn't work in Mozilla either this way.

    Should I change something more?

  • #4
    jkd
    jkd is offline
    Senior Coder jkd's Avatar
    Join Date
    May 2002
    Location
    metro DC
    Posts
    3,163
    Thanks
    1
    Thanked 18 Times in 18 Posts
    The text node is being targeted. Use e.target.parentNode;

  • #5
    New to the CF scene
    Join Date
    Jun 2003
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes!
    Now it works in NS and IE, but not in Mozilla ... how do i combine everything to make it work for all browsers?

  • #6
    New to the CF scene
    Join Date
    Jun 2003
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Anybody?


  •  

    Posting Permissions

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