IE Firefox compatibility

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • daveybteacher
    New Member
    • Nov 2007
    • 1

    #1

    IE Firefox compatibility

    Hi, I'm an IT teacher in England running a BTEC course for A-level students, the unit is 'Client -side cutomisation of web pages' and deals specifically with CSS and Javascript, for 1 of the assessment criteria I need to get students to 'explain how web pages using scripts are implemented in two different browsers', now the obvious browsers there I assume would be IE and Firefox and I will need to set the students a task which will require them to write 2 different implementations of javascript to perform the same task (ie because browser incompatibiliti es won't run the same code the same way).

    Having checked a lot of blogs tonight I'm finding this difficult, particularly as the students are novice coders and the obscurities of the latest bits of W3C DOM to be implemented in latest browser versions is probably beyond their capabilities. So I suppose my question would be 'is there a simple task or procedure in javascript that is required to be written differently for IE and Firefox, thanks, Dave
  • Ferris
    New Member
    • Oct 2007
    • 101

    #2
    Hi:
    I write an example for you:


    [HTML]
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Untitl ed Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    </head>

    <body>
    <input type="button" id="btn_OK" value="OK" />

    <script language="javas cript" type="text/javascript">
    <!--
    //for IE
    //document.getEle mentById("btn_O K").attachEvent ("onclick",func tion(){alert("O K");});
    //for FireFox
    //document.getEle mentById("btn_O K").addEventLis tener("click",f unction(){alert ("OK");} , false);
    //for Both
    //document.getEle mentById("btn_O K").onclick = function(){aler t("OK");};
    -->
    </script>
    </body>
    </html>


    [/HTML]


    By the way: if I were you, I will not require my students to write Non-Portable code.


    hope it helps.

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      Originally posted by daveybteacher
      I will need to set the students a task which will require them to write 2 different implementations of javascript to perform the same task (ie because browser incompatibiliti es won't run the same code the same way).
      ...
      So I suppose my question would be 'is there a simple task or procedure in javascript that is required to be written differently for IE and Firefox, thanks, Dave
      Check out Browser Bugs, Quirks and Inconsistencies and A Guide to Coding Cross-Browser Scripts which will give you some ideas.

      The obvious example as used by Ferris is event handling where IE is notoriously bad (it has its own non-standard model).

      Whatever you do, do not use ugly ten-years old code which used to differentiate between IE and Netscape using document.all and document.layers .

      Hope that helps.

      Comment

      • drhowarddrfine
        Recognized Expert Expert
        • Sep 2006
        • 7434

        #4
        If this helps, you can check on the level of DOM support in your browser. As you will see, IE is almost 10 years behind while Firefox and Opera are only three or so.

        Comment

        Working...