Results 1 to 20 of 20

Thread: JavaScript: (Why IE Sucks)

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2002
    Location
    Durham, NC, US
    Posts
    218

    JavaScript: (Why IE Sucks)

    Consider the following code:
    Code:
    <html>
      <head>
        <title>Foo</title>
      </head>
      <body>
        <select id="mySelect">
        </select>
        <script type="text/javascript">
          myNewOption = document.createElement("option");
          myNewOption.text = "foo";
          myNewOption.value = 1;
          document.getElementById("mySelect").add(myNewOption);
        </script>
      </body>
    </html>
    The following works in IE 6 on Windows 2000, but not in Mozilla 1.4 on Windows XP. Mozilla's complaint is that an arguement is missing from .add(). Yes, I admit that is true, but there is no element that I want the new one added before. What do I do?

    Update: I've tried null as the second arguement. It works in Mozilla, but now breaks in IE. I suspect that this is the correct way, but I agree with MS, this arguement should be optional. I don't agree with MS that they shouldn't support the standard, though. I'm still looking for a common answer.
    Last edited by Travis G; Jan 26th, 2004 at 03:30 PM.
    Travis, Kung Foo Journeyman

    Web Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.5 Guide and Reference
    Perl: Documentation, Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
    OSS: Mozilla, MySQL (Manual)

  2. #2
    Frenzied Member axion_sa's Avatar
    Join Date
    Jan 2002
    Location
    Joburg, RSA
    Posts
    1,724
    Can't say much for Mozilla, but Opera & IE 6 work fine:
    Code:
    <html>
      <head>
        <title>Foo</title>
      </head>
      <body>
        <select id="mySelect">
        </select>
        <script type="text/javascript">
          myNewOption = document.createElement("option");
          myNewOption.text = "foo";
          myNewOption.value = 1;
          document.getElementById("mySelect").options[0] = myNewOption;
        </script>
      </body>
    </html>

  3. #3
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Try appendChild instead of add.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Sep 2002
    Location
    Durham, NC, US
    Posts
    218
    Code:
            document.getElementById("baseSelect").options[document.getElementById("baseSelect").options.length] = newOption;
    This works in both. appendChild probably works, but I have to treat newOption as a Node and not an Element, so I have to set values and stuff differently.
    Travis, Kung Foo Journeyman

    Web Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.5 Guide and Reference
    Perl: Documentation, Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
    OSS: Mozilla, MySQL (Manual)

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Sep 2002
    Location
    Durham, NC, US
    Posts
    218
    Code:
    var inputActive = document.createElement("input");
    inputActive.type = "checkbox";
    inputActive.checked = Boolean(arrBases[selectIndex][3] == 1);
    Code:
    var inputActive = document.createElement("input");
    inputActive.type = "checkbox";
    if (arrBases[selectIndex][3] == 1) {
         inputActive.checked = true;
    }
    else {
      inputActive.checked = false;
    }

    Neither of these work in IE, either.
    Travis, Kung Foo Journeyman

    Web Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.5 Guide and Reference
    Perl: Documentation, Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
    OSS: Mozilla, MySQL (Manual)

  6. #6
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    You wouldn't believe all the things that don't work in IE
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  7. #7
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    Actually, I'm surprised at all the things that DO work in IE, that don't work in Netscape.

    I know its not the politically correct stance, but I truly believe since IE controls 90%+ of the browser market, that I'm FAR more concerned getting tricky scripts to run in IE, than I would ever be for the 1 or 2 users that use Netscape /Mozilla.

    And since I am not running a e-commerce site, anyone that can't use it, doesn't affect our model.

  8. #8
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    I wish M$ got their CSS working properly. damn lazy bastards.

    sorry for the random blurt but it had to be said.
    Have I helped you? Please Rate my posts.

  9. #9
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    Maybe the Internet would be better off back in the days of Kermit and Xmodem.

    Just text and nothing else. Those were easily agreed upon standards.

    [))]

  10. #10
    Frenzied Member vbNeo's Avatar
    Join Date
    May 2002
    Location
    Jutland, Denmark
    Posts
    1,994
    Originally posted by nemaroller
    Maybe the Internet would be better off back in the days of Kermit and Xmodem.

    Just text and nothing else. Those were easily agreed upon standards.

    [))]
    Or let's all use Lynx
    "Lies, sanctions, and cruise missiles have never created a free and just society. Only everyday people can do that."
    - Zack de la Rocha


    Hear me roar.

  11. #11

    Thread Starter
    Addicted Member
    Join Date
    Sep 2002
    Location
    Durham, NC, US
    Posts
    218
    Originally posted by nemaroller
    Actually, I'm surprised at all the things that DO work in IE, that don't work in Netscape.
    Uhm... such as?
    Travis, Kung Foo Journeyman

    Web Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.5 Guide and Reference
    Perl: Documentation, Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
    OSS: Mozilla, MySQL (Manual)

  12. #12
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Nah, lynx sucks. Use links2
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  13. #13

    Thread Starter
    Addicted Member
    Join Date
    Sep 2002
    Location
    Durham, NC, US
    Posts
    218
    Odd, I have to launch IE to start a new thread here at VBForums. This is something new. The new thread image doesn't appear in Mozilla. It may be because of my user style sheet, which is supposed to not display banner ads from major distributors.
    Travis, Kung Foo Journeyman

    Web Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.5 Guide and Reference
    Perl: Documentation, Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
    OSS: Mozilla, MySQL (Manual)

  14. #14
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    Originally posted by Travis G
    Uhm... such as?
    Well, for one, the onkeydown event.

  15. #15
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    onkeydown works perfectly well in Mozilla.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  16. #16
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    I didn't test Mozilla (i'm sure it works there), but Netscape 6/7, it is broke.

    "Unfortunately, the onkeydown event is broken in Netscape 6 and 7, so this solution does not work in those browsers."

    http://www.webreference.com/programm...8/2/index.html

  17. #17
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    does that include 7.1? the newest one?

    if so, that's very very silly of them.
    Have I helped you? Please Rate my posts.

  18. #18

    Thread Starter
    Addicted Member
    Join Date
    Sep 2002
    Location
    Durham, NC, US
    Posts
    218
    Originally posted by CornedBee
    onkeydown works perfectly well in Mozilla.
    I didn't realize there was that much of a difference between Netscape and Mozilla. I guess they share Gecko and nothing more.
    Travis, Kung Foo Journeyman

    Web Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.5 Guide and Reference
    Perl: Documentation, Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
    OSS: Mozilla, MySQL (Manual)

  19. #19
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    put it this way, Mozilla always works, as long as you've got correct code and use a new version of Mozilla (or Mozilla FireFox), it'll work.
    Have I helped you? Please Rate my posts.

  20. #20
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Let's put it this way, Netscape is usually based on outdated Mozilla builds. 6 was based on 0.9, 7 on 1.0.1, 7.1 on 1.4. Current version is 1.6.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

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



Click Here to Expand Forum to Full Width