Closed
Bug 212817
Opened 21 years ago
Closed 21 years ago
Simple javascript that works on IE, Opera, Safari, but not on Mozilla OR Firebird for Windows and Linux
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
RESOLVED
DUPLICATE
of bug 114461
People
(Reporter: jerry-mozilla, Unassigned)
References
()
Details
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4) Gecko/20030624
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4) Gecko/20030624
The page and javascript below will renders correctly on IE, Opera, and Safari
but fails under Mozilla 1.4/XP with Venkman, Firebird .6/XP, and Mozilla
1.2/Linux. Under IE, Opera and Safari, it prints out two tables. Under
Mozilla, only one table. Venkman says it dies at this
line:
outputArray( "Array n2 contains", n2 );
Error ``outputArray is not defined'' [xs] in file
``http://www.theashergroup.com/junk/InitArray.html'', line 30,
character 0.
Stopped for error handler.
#0: function initializeArrays() in
<http://www.theashergroup.com/junk/InitArray.html> line 30
028:
029: outputArray( "Array n1 contains", n1 );
030: outputArray( "Array n2 contains", n2 );
031: }
032:
A copy of this page is at
http://www.theashergroup.com/junk/InitArray.html
Questions:
A) What is wrong with that example and page?
B) Where is the best place to ask similar questions?
C) How do I set a breakpoint or a "future breakpoint" at line 29?
D) How do I step through this using Venkman? I can't figure
out how to start the script.
Thank you,
Jerry
<?xml version = "1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-- Fig. 11.3: InitArray.html -->
<!-- Initializing an Array -->
<html xmlns =" http://www.w3.org/1999/xhtml">
<head>
<title>Initializing an Array</title>
<script type =" text/javascript">
<!--
// this function is called when the <body> element's
// onload event occurs
function initializeArrays()
{
var n1 = new Array( 5 ); // allocate 5-element Array
var n2 = new Array(); // allocate empty Array
// assign values to each element of Array n1
for ( var i = 0; i < n1.length; ++i )
n1[ i ] = i;
// create and initialize five-elements in Array n2
for ( i = 0; i < 5; ++i )
n2[ i ] = i;
outputArray( "Array n1 contains", n1 );
outputArray( "Array n2 contains", n2 );
}
// output "header" followed by a two-column table
// containing subscripts and elements of "theArray"
function outputArray( header, theArray )
{
document.writeln( "<h2>" + header + "</h2>" );
document.writeln( "<table border = \"1\" width =" +
"\"100%\">" );
document.writeln( "<thead><th width = \"100\"" +
"align = \"left\">Subscript</th>" +
"<th align = \"left\">Value</th></thead><tbody>" );
for ( var i = 0; i < theArray.length; i++ )
document.writeln( "<tr><td>" + i + "</td><td>" +
theArray[ i ] + "</td></tr>" );
document.writeln( "</tbody></table>" );
}
// -->
</script>
</head><body onload =" initializeArrays()"></body>
</html>
<!--
**************************************************************************
* (C) Copyright 2002 by Deitel & Associates, Inc. and Prentice Hall.
*
* All Rights Reserved.
*
*
*
* DISCLAIMER: The authors and publisher of this book have used their
*
* best efforts in preparing the book. These efforts include the
*
* development, research, and testing of the theories and programs
*
* to determine their effectiveness. The authors and publisher make
*
* no warranty of any kind, expressed or implied, with regard to these
*
* programs or to the documentation contained in these books. The
authors *
* and publisher shall not be liable in any event for incidental or
*
* consequential damages in connection with, or arising out of, the
*
* furnishing, performance, or use of these programs.
*
**************************************************************************
-->
Reproducible: Always
Steps to Reproduce:
1. Enable Javascript
2. Load the page
3. Count the tables
Actual Results:
I saw one table
Expected Results:
Mozilla should have displayed two tables
Comment 1•21 years ago
|
||
http://devedge.netscape.com/viewsource/2002/venkman/01/
I have no idea what's wrong with the code though.
Reporter | ||
Comment 2•21 years ago
|
||
It has something to do with the onload() statement.
If I change the script from running with onload() to running within the body by
calling start(), then things work as expected.
When the function start() is called in the onload, it is broken.
A more distilled script can be found at
http://www.theashergroup.com/junk/InitArray2.html
which contains nothing about arrays....
Reporter | ||
Comment 3•21 years ago
|
||
Compare
http://www.theashergroup.com/junk/InitArray2.html
and
http://www.theashergroup.com/junk/InitArray3.html
InitArray2 performs the computation in the onload InitArray3 is the same
function called during the body. InitArray2 doesn't work. InitArray3 works.
Both work in IE, Safari, Opera.
Comment 4•21 years ago
|
||
> A) What is wrong with that example and page?
Calling document.write() on a document that is not in the middle of loading
implicitly calls document.open(). This wipes out the old document that used to
be there and clears the global JS scope. So when you do:
outputArray( "Array n1 contains", n1 );
outputArray( "Array n2 contains", n2 );
The first call wipes out the global scope and "outputArray" in undefined after that.
> B) Where is the best place to ask similar questions?
The netscape.public.mozilla.dom newsgroup is probably the best match for this
sort of question (involving interaction with the DOM).
> C) How do I set a breakpoint or a "future breakpoint" at line 29?
> D) How do I step through this using Venkman? I can't figure
> out how to start the script.
A JS engine bug is not exactly the right place to look for help on using Venkman
(as in, I don't know). ;)
Status: UNCONFIRMED → RESOLVED
Closed: 21 years ago
Resolution: --- → INVALID
Reporter | ||
Comment 5•21 years ago
|
||
Hi, thanks for the response. I am still a bit concerned. I am concerned in
that I see a different behavior in four different other javascript
implementations, namely the javascript implementations in IE on XP, Opera on XP,
Opera 7 on Linux, and Safari on OS/X. Each of these other javascript
implementations display two tables. Mozilla displays one table.
Now I would imagine there are conflicting goals: one is to support a standard,
and two would be to be as compatible as possible. (I hate having to use IE to
operate my bank's web forms.)
Is Mozilla implementing the standard? Are the other browsers violating the
standard? Is the standard vague? Would it violate the standard if Mozilla's
behavior was the same as the other browsers?
Are their official Mozilla guidelines that come into play at times like these?
Status: RESOLVED → UNCONFIRMED
Resolution: INVALID → ---
Comment 6•21 years ago
|
||
Yes, the official Mozilla guideline is that it's the module owner's decision.
There is an earlier bug on this very issue, marked invalid, if I recall. Over
to DOM to have this marked duplicate....
Assignee: rogerl → dom_bugs
Component: JavaScript Engine → DOM Level 0
QA Contact: pschwartau → ashishbhatt
Whiteboard: DUPEME
Comment 7•21 years ago
|
||
Dup of bug 114461. (bz: that bug has never been marked as invalid.)
*** This bug has been marked as a duplicate of 114461 ***
Status: UNCONFIRMED → RESOLVED
Closed: 21 years ago → 21 years ago
Resolution: --- → DUPLICATE
You need to log in
before you can comment on or make changes to this bug.
Description
•