This javascript runs on IE and Opera and Safari and crashes under Mozilla?

The page and javascript below will renders correctly on IE, Opera, and Safari
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.                 
   *
 **************************************************************************
-->
0
jerry
7/15/2003 8:43:24 PM
netscape.mozilla.jseng 1530 articles. 0 followers. Follow

0 Replies
219 Views

Similar Articles

[PageSpeed] 30

Reply: