Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Can you help me understand this javascript example that runs on IE and Opera and crashes under Mozilla?

Reply
Thread Tools

Can you help me understand this javascript example that runs on IE and Opera and crashes under Mozilla?

 
 
Jerry Asher
Guest
Posts: n/a
 
      07-15-2003
The page and javascript below will render correctly on IE and Opera,
but fails under Mozilla. Under IE and Opera, 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.
*
************************************************** ************************
-->
 
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


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in running a basic code in python 3.3.0 that includes HTML file Satabdi Mukherjee Python 1 04-04-2013 07:48 PM
A router running under WinXP runs under Windows Vista too? Peter Wagner Wireless Networking 12 02-04-2008 11:02 PM
Comparisons of IE, Opera and Firefox on DOM (Javascript/CSS) support(Opera wins) Bob HTML 24 05-21-2006 05:31 PM
help : my jar file is not running under linux terminal , but it runs under JbuilderX ide bronby Java 1 07-15-2005 07:23 AM
cgi script runs under Opera, but not firefox nephish@xit.net Python 9 06-11-2005 10:47 PM



Advertisments