HTML and CSS Reference
In-Depth Information
Apply Your Knowledge
1. Predict the Result. Given the following code, what will happen when the user clicks
the button?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>JavaScript Practice</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">
<!-- <![CDATA[
function mystery()
{
alert('hello');
}
// ]]> -->>
</script>
</head>
<body>
<h1>Using JavaScript</h1>
<input type="button" value="click me" onclick="mystery();" />
</body>
</html>
2. Fill in the Missing Code. This Web page should prompt the user for the name of a
song and print the song name in the document. The missing code is indicated by
"_" . Fill in the missing code.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>JavaScript Practice</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<h1>Using JavaScript</h1>
<script type="text/javascript">
<!-- <![CDATA[
var userSong;
userSong = _ ("Please enter your favorite song title.");
document. _ ( _ );
// ]]> -->
</script>
</body>
</html>
3. Find the Error. When this page is loaded in the Web browser it is supposed to dis-
play an error message if the user does not have any data in the Name input box. It
is not working properly, and instead submits the form regardless of the missing
 
Search WWH ::




Custom Search