Professional Documents
Culture Documents
Javascript Scripting Language: Client-Side Scripting Enhances Functionality Andappearance
Javascript Scripting Language: Client-Side Scripting Enhances Functionality Andappearance
1 of 1
<script type = "text/javascript">
<!--
document.writeln( "<h1>Welcome to<br />JavaScript" +
"<br />Programming!</h1>" );
// -->
</script>
</head><body></body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" Outline
</script>
</head>
<body> welcome4.html
<p>Click Refresh (or Reload) to run this script again.</p>
</body>
</html>
1 of 1
Dynamic Pages
• A script can adapt the content based on explicit input from
the user or other information
– System clock: Time of day
– Hidden input
– Cookies
• User input can be collected by invoking the prompt method
of a window object
– This will display a dialog box that prompts user for input
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" Outline
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<title>Using Prompt and Alert Boxes</title>
welcome5.html
// read the name from the prompt box as a string
(1 of 2)
name = window.prompt( "Please enter your name", "GalAnt" );
</script>
When the user clicks OK, the value
typed by the user is returned to the
This is the program as a string.
prompt
to the user.
welcome6.html
<script type = "text/javascript">
It can invoke all the methods of
that object class
<!--
if ( hour < 6 )
document.write( "<h1>Good Afternoon, " );
welcome6.html
if ( hour >= 6 )
}
(2 of 3)
document.write( "<h1>Good Evening, " );
</script>
47 <body>
</head>
48 <p>Click Refresh (or Reload) to run this script again.</p>
49 </body>
50 </html>