SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2004
    Location
    London
    Posts
    50
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Hide JavaScript from IE on Mac

    I've got the following JavaScript I'm using for a dropdown menu, and it's causing crazy things to happen in IE on Mac! I'd like to hide the script from IE Mac - any help on what needs to be done to do this would be much appreciated!

    Code:
    sfHover = function() {
    var sfEls = document.getElementById("nav").getElementsByTagName("LI");
    for (var i=0; i<sfEls.length; i++) {
    sfEls[i].onmouseover=function() {
    this.className+=" sfhover";
    }
    sfEls[i].onmouseout=function() {
    this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
    }
    }
    }
    if (document.all&&document.getElementById) window.onload=sfHover;
    Webcredible for usability & accessibility.
    Read all about the Disability Discrimination Act (DDA)

  2. #2
    SitePoint Zealot
    Join Date
    Aug 2004
    Location
    Perth, Western Australia
    Posts
    166
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What do you mean when you say you want to 'hide it from IE on Mac'?
    POSTED WITH CARE BY JORDIE, WEBMISTRESS OF WWW.A-SPLODE.NET

  3. #3
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by Jordie
    What do you mean when you say you want to 'hide it from IE on Mac'?
    He doesn't want the script to run if the browser is IE/Mac.

    trenton, your issue isn't really with the script I think. IE/Mac does some very weird things when you give an element multiple CSS classes like you're doing in your script. If you can find a way around that (i.e. maybe by replacing the classname with something else, rather than adding another class to it), then you might not need to hide it. If you can't find a way around it however, this code should work:
    Code:
    var ua = navigator.userAgent.toLowerCase();
    if (ua.indexOf('mac') == -1 && ua.indexOf('IE') == -1)
    {
      //throw your function in here.
    }
    Remember that some browsers can fake the user agent header to appear to be another browser, so this might not be the best way to filter out IE/Mac users.

  4. #4
    SitePoint Enthusiast
    Join Date
    Mar 2004
    Location
    London
    Posts
    50
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks - it's working a treat now!
    T
    Webcredible for usability & accessibility.
    Read all about the Disability Discrimination Act (DDA)


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
  •