question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • richk

    question

    <html>
    <head>
    <title>Untitled </title>
    <script language="Javas cript">
    <!--hide me from older browsers
    var seconds_per_min ute=60;
    var minutes_per_hou r=60;
    var hours_per_day= 24;
    var seconds_per_day =
    seconds_per_min ute*minutes_per _hour*hours_per _day;
    // end hiding stuff-->
    </script>
    </head>
    <body>
    <h1>Do you know how many seconds are in a day</h1>
    <h2>I Do!</h2>

    <h1>My calculations show that</h1>
    <script language="Javas cript">
    <!--
    window.document .write("there are");
    window.document .write(seconds_ per_day);
    window.document .write("seconds in a day.")
    //-->
    </script>


    </body>
    </html>


    this is a simple script I know..But i have a question why are the
    Write commands lines in a separate script. Can they be out in the
    first script, if not why..The second script has something to do with
    the first one..
  • Lee

    #2
    Re: question

    richk said:[color=blue]
    >
    ><html>
    ><head>
    > <title>Untitled </title>
    ><script language="Javas cript">
    ><!--hide me from older browsers
    >var seconds_per_min ute=60;
    >var minutes_per_hou r=60;
    >var hours_per_day= 24;
    >var seconds_per_day =
    >seconds_per_mi nute*minutes_pe r_hour*hours_pe r_day;
    >// end hiding stuff-->
    ></script>
    ></head>
    ><body>
    ><h1>Do you know how many seconds are in a day</h1>
    ><h2>I Do!</h2>
    >
    ><h1>My calculations show that</h1>
    ><script language="Javas cript">
    ><!--
    >window.documen t.write("there are");
    >window.documen t.write(seconds _per_day);
    >window.documen t.write("second s in a day.")
    >//-->
    ></script>
    >
    >
    ></body>
    ></html>
    >
    >
    >this is a simple script I know..But i have a question why are the
    >Write commands lines in a separate script. Can they be out in the
    >first script, if not why..The second script has something to do with
    >the first one..[/color]


    The write() calls appear at the place within the HTML
    where you want the generated HTML to appear.

    The first code block could be merged into the second,
    but the second could not be moved into the first, or
    the generated HTML would appear out of place.

    People often put parts of the script that are not
    actually writing HTML in the head, rather than in
    the body.

    It's largely a matter of personal preference, unless
    one form or the other is easier to maintain in any
    particular case.

    Comment

    Working...