Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Web Design (WordPress, Joomla, etc.) javascript anamolies: mac vs pc

  • javascript anamolies: mac vs pc

    Posted by Rob Hindley on April 9, 2005 at 1:34 am

    I have been scripting some drop down menus but have found that Safari and IE on a Mac doesn’t slide the sub-menus but IE in Windows does. I was of the understanding that the js language was totally cross-platform. Any thoughts/suggestions?

    Gord replied 21 years, 1 month ago 2 Members · 2 Replies
  • 2 Replies
  • Gord

    April 10, 2005 at 1:51 pm

    Hello Rob.
    Firstly, the version of Javascript could be different (1.1 or 1.5 etc..).
    Secondly, and more likely, Javascript code manipulates the browsers document object model(DOM).Whilst very similar, no two browsers DOM are exactly the same, meaning that some browsers may not recognise the ‘element’ your code refers to .eg: code refering to document.layers will be ok on Netscape 4 browsers but will mean nothing to IE.
    Thirdly, browser versions for Windows are different from browser versions for the Mac & each will have a few quirks & strange behaviors.

    If you really want to write & understand the code rather than search for good cross-browser compatible drop down menus already written, you need to do a search for “Javascript browser compatibility ‘strategy’ ‘techniques’ ‘help’ …etc”

    A common approach is to test for the feature before executing code and if the feature is not detected , supply alternative options using the if syntax.

    if(document layers){ .. do this code… document.layers is supported
    }
    else if(document.getElementById){.. do this code… document.getElementById is supported
    }
    else { .. some simple static code
    }

    If you can post your code up on the web I’ll have a look.

    Hope this helps
    Gord

  • Gord

    April 10, 2005 at 1:51 pm

    Hello Rob.
    Firstly, the version of Javascript could be different (1.1 or 1.5 etc..).
    Secondly, and more likely, Javascript code manipulates the browsers document object model(DOM).Whilst very similar, no two browsers DOM are exactly the same, meaning that some browsers may not recognise the ‘element’ your code refers to .eg: code refering to document.layers will be ok on Netscape 4 browsers but will mean nothing to IE.
    Thirdly, browser versions for Windows are different from browser versions for the Mac & each will have a few quirks & strange behaviors.

    If you really want to write & understand the code rather than search for good cross-browser compatible drop down menus already written, you need to do a search for “Javascript browser compatibility ‘strategy’ ‘techniques’ ‘help’ …etc”

    A common approach is to test for the feature before executing code and if the feature is not detected , supply alternative options using the if syntax.

    if(document layers){ .. do this code… document.layers is supported
    }
    else if(document.getElementById){.. do this code… document.getElementById is supported
    }
    else { .. some simple static code
    }

    If you can post your code up on the web I’ll have a look.

    Hope this helps
    Gord

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy