// Inserts text dynamically in the document when it is called
// Note that all text are dynamically inserted into the document
// when a call to this function are made in the BODY part of the file.
function sayHello ()
{
document.write( "I see that the time is <B>" + getTime() + "</B>, so I wish you" );
if(getHourOfDay()<5 || getHourOfDay()>19)
document.write('<FONT COLOR="2C396D"> a good night!</FONT>');
else
{
if ( getHourOfDay() <11)
{
document.write('<FONT COLOR="52A553"> a good morning!</FONT>');
}
else
{
document.write('<FONT COLOR="ED363C"> a good day!</FONT>');
}
}
}
// -->
</script>
</head>
<body bgcolor=FFFFFF text=000000>
<h1>JavaScript Dynamic Document</h1>
<p><b>This stationery page contains JavaScript that creates a dynamic page</b></p>
<p>Here is an example on how JavaScript can be used to provide a dynamic page that will change its contents depending upon the local time specified in the browser's system and the OS that is used by the reader.</p>
<!-- 1) Let the reader know the browser ID used
(this is often logged by servers for keeping statistics) -->
'<P><FONT COLOR="385FD1">Very, very nice to see that you are using MacOS!</FONT>');
else
document.write(
'<P>Sad too see that you are not using a Mac to view this page.')
// -->
</script>
<hr>
<b>How to use:</b><br>
<p>Four small scripts are embedded inside the text contents of this file. The scripts are executed - and inserts text - when the page is being loaded. View the source file to see how this is done. Every function is commented.</p>
<p>
Replace the contents inside the script with calls to your own test functions and add text you want to have displayed inside the <font color="FF3366"><code>document.write()</code></font> function in the script. It is recommended to create functions for complex scripts and place these in the HEAD section, see the <tt>sayHello</tt> function for an example of this. </p>
<p>
Make sure that all text is placed inside the <font color="FF3366"><code>document.write()</code></font> function, otherwise it will not look good on browsers that don't support JavaScript.</p>
<p>
Edit this page or copy selected scripts to create your own dynamic page!</p>
<hr>
<p>
<b>Example code for the first dynamic text above:</b>
<pre>Welcome <B><SCRIPT LANGUAGE="JavaScript">
<!--
document.write(navigator.userAgent)
// -->
</SCRIPT></B>!
</pre>
<p>Note that the text "<b>Welcome !</b>" is the only text that will be displayed in browsers that don't support JavaScript.</p>
<hr>
<p>
<b>This function located in the HEAD section returns true if the browser is running on a Mac:</b></p>