Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Is it a bug?

Reply
Thread Tools

Is it a bug?

 
 
Paul Gorodyansky
Guest
Posts: n/a
 
      07-02-2003
Hi,

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/r...keyboards.aspx

Is it a bug in Netscape/Mozilla JavaScript implementation?

--
Regards,
Paul Gorodyansky
"Cyrillic (Russian): instructions for Windows and Internet":
http://ourworld.compuserve.com/homepages/PaulGor/
 
Reply With Quote
 
 
 
 
Lasse Reichstein Nielsen
Guest
Posts: n/a
 
      07-02-2003
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/r...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.opt ions[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.'
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57