Is it a bug?

Discussion in 'Javascript' started by Paul Gorodyansky, Jul 2, 2003.

  1. Paul Gorodyansky, Jul 2, 2003
    #1
    1. Advertising

  2. Paul Gorodyansky <> writes:

    > The following page's JavaScript does not work in Netscape 7.1/
    > Mozilla 1.3+ (that is, an image does NOT appear if one chooses
    > a keyboard layout):
    > http://www.microsoft.com/globaldev/reference/keyboards.aspx
    >
    > Is it a bug in Netscape/Mozilla JavaScript implementation?


    Why would you think it is a bug in the browser, and not in the javascript
    code itself? Which is more likely?

    It is a bug in the Javascript code. It is an accident if it works in
    any browser (IE is known to be very accident prone).

    More precisely, the error is in the line:
    onChange="chooseKeyboard(document.choose.state.options[state.selectedIndex].value)"

    Some browsers allow you to refer to named forms as properties of the
    document area. It is still not as safe an assumption as writing
    document.forms['choose']
    Some browsers also allow toy to refer to form elements as properties
    of the form. It is safer to use the "elementes" collection.

    Very few browsers allow you to access named form elements as properties
    of the global object. That is what the above line tries:
    state.selectedIndex
    There is no global variable called "state". What should be writte is:

    onchange="var select=document.forms['choose'].elements['state'];
    chooseKeyboard(select.options[select.selectedIndex].value);"

    Then it will work in other browsers than IE.
    /L
    --
    Lasse Reichstein Nielsen -
    Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
    'Faith without judgement merely degrades the spirit divine.'
    Lasse Reichstein Nielsen, Jul 2, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John

    Re: BUG? OR NOT A BUG?

    John, Sep 20, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    536
  2. RedEye
    Replies:
    2
    Views:
    571
    Jason Kester
    Dec 13, 2005
  3. Michel Joly de Lotbiniere

    Bug Parade Bug 4953793

    Michel Joly de Lotbiniere, Nov 30, 2003, in forum: Java
    Replies:
    4
    Views:
    631
    Michel
    Dec 2, 2003
  4. DarkSpy
    Replies:
    4
    Views:
    876
    tom_usenet
    Jun 27, 2003
  5. Steve Holden
    Replies:
    1
    Views:
    386
    Behrang Dadsetan
    Jul 2, 2003
Loading...

Share This Page