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

Discussion in 'Javascript' started by Jerry Asher, Jul 15, 2003.

  1. Jerry Asher

    Jerry Asher Guest

    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.
    *
    **************************************************************************
    -->
    Jerry Asher, Jul 15, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. bronby
    Replies:
    1
    Views:
    582
    Andrew Thompson
    Jul 15, 2005
  2. Derek
    Replies:
    10
    Views:
    591
    tom_usenet
    Jul 19, 2004
  3. Bob
    Replies:
    24
    Views:
    1,507
  4. Replies:
    9
    Views:
    562
  5. Joseph Geretz

    How can I ensure my site runs under framework 1.0?

    Joseph Geretz, Aug 24, 2003, in forum: ASP .Net Web Services
    Replies:
    6
    Views:
    133
    Joseph Geretz
    Aug 25, 2003
Loading...

Share This Page