Due Tuesday Oct. 8 at 11:59pm.
Carefully study the examples on the resources page: Javascript events (helpful for task 1) and Javascript directly in the page (helpful for tasks 2,3):
Open a new file events.html
and copy the following
starting code into it:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>Changing the dimensions of an image</title>
</head>
<body style="text-align:center">
<h1>Changing the dimensions of an image</h1>
<!-- this is an image that will be changing. Note the id -->
<img id="apple" src="apple.jpg" alt="A picture that changes" />
<h3>Changing an element in a page from another element</h3>
<p>
Add javascript code to the wizard image to change the height and
width of the apple image above, as specified in comments.
</p>
<p>
<img src="wizard.jpg" alt="A picture of a wizard" height="200"
/>
<h3>Changing color and background of elements</h3>
<p>
Add the code to change the color of the text to red when the
wizard image is clicked.
</p>
<p>
<img src="wizard.jpg" alt="A picture of a wizard" height="200"
onmouseover =
"document.getElementById('colorchange').style.backgroundColor = 'yellow';"
/>
</p>
<div id="colorchange">
This text will change its color and background.
</div>
</body>
</html>
Also save the images of an apple and a wizard from the examples if you haven't done so already. You need to write the code for, and test, the following:
style.color
(not
just color
to change text properties.innerHTML
setting that
we used in the examples in class).story.html
on your Desktop.
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>
A story program for CSci 1001
</title>
</head>
<body>
<h1>A story program for CSci 1001</h1>
<p>
<script type="text/javascript">
// variables
var person = "Mary";
var place = "Morris";
// add more variables here:
document.write(person + " lives in " + place);
// continue the story here:
</script>
</p>
</body>
</html>
person
and
place
. Feel free to change the beginning. Check your
program after every change. var person = "Mary";
to
var person = "Peter";
Reload your page, and see it change.Change your solution to the previous task by letting the user enter the person's name as a prompt, then print a story with that name. You may take more inputs via a prompt, but that's not required. You may submit separate solutions for tasks 2 and 3 or just one for both.
This page is a part of CSci 1001 course web site.