question

R

richk

<html>
<head>
<title>Untitled</title>
<script language="Javascript">
<!--hide me from older browsers
var seconds_per_minute=60;
var minutes_per_hour=60;
var hours_per_day= 24;
var seconds_per_day=
seconds_per_minute*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="Javascript">
<!--
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..
 
L

Lee

richk said:
<html>
<head>
<title>Untitled</title>
<script language="Javascript">
<!--hide me from older browsers
var seconds_per_minute=60;
var minutes_per_hour=60;
var hours_per_day= 24;
var seconds_per_day=
seconds_per_minute*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="Javascript">
<!--
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..


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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top