Opera JavaScript Flaw--with Statement Problems
This document demonstrates an apparent flaw in the Opera Web browser.
For some objects, particularly form elements, the
with statement does not appear to work
properly.
Code
JavaScript functions like the following are attached to the buttons on the
form below.
function btnSetFieldsA_OnClick ()
{
with (document.frmTest) {
txtBox1.value = "Method A";
}
}
function btnSetFieldsB_OnClick ()
{
with (document.frmTest.txtBox1) {
value = "Method B";
}
}
function btnResetField_OnClick ()
{
with (document.frmTest) {
txtBox1.value = "-----";
}
}
Demonstration and Results
Load this document in the Opera Web browser and click the Method A
and Method B buttons. The code attached to the Method A
button will work properly, causing the text Method A to appear in
the text box. The code attached to the Method B button, however,
will not work properly in the Opera browser, and the text in the text box
will not change.
This behavior was also observed when the with
statement was used directly in the
<INPUT> tags for the buttons.
Discovered By
This behavior was discovered by Charles L. Taylor,
who also prepared this example.
Last update: 11 Feb 1999 --
(Copyright) --
(Contact)