2023 In this project you will create a Web page with an animation | Assignment Collections
Computer Science 2023 A+ Work
2023 In this project you will create a Web page with an animation | Assignment Collections
In this project, you will create a Web page with an animation of a man
using a jackhammer. Your Exercises folder for Chapter 10 contains 11 images that are required for this program: jackhammer0.gif through jackhammer10.gif.
1. Create a new document in your text editor.
2. Type the <!DOCTYPE> declaration, <html> element, header information, and the <body> element. Use the strict DTD and “Jackhammer” as the content of the <title> element.
3. Add the following script section to the document head:
<script type=”text/javascript”>
/* <![CDATA[ */
/* ]]> */
</script>
4. Add the following text and elements to the document body. The text and elements include an <img> element to display the image, and a form with buttons that controls the animation.
<h1>Jackhammer Man</h1>
<p><img src=”jackhammer1.gif” height=”113″ width=”100″
alt=”Image of a man with a jackhammer.” /></p>
<form action=”” enctype=”text/plain”><p>
<input type=”button”
value=”Start Bouncing”
onclick=”startBouncing();” />
<input type=”button” value=”Stop Bouncing”
onclick=”clearInterval(begin);” /></p>
</form>
5. Add the following variable declarations to the script section:
var jackhammers = new Array(11);
var curJackhammer = 0;
var direction;
var begin;
jackhammers[0] = “jackhammer0.gif”;
jackhammers[1] = “jackhammer1.gif”;
jackhammers[2] = “jackhammer2.gif”;
jackhammers[3] = “jackhammer3.gif”;
jackhammers[4] = “jackhammer4.gif”;
jackhammers[5] = “jackhammer5.gif”;
jackhammers[6] = “jackhammer6.gif”;
jackhammers[7] = “jackhammer7.gif”;
jackhammers[8] = “jackhammer8.gif”;
jackhammers[9] = “jackhammer9.gif”;
jackhammers[10] = “jackhammer10.gif”;
6. Now add the following functions to the script section, which
control the animation:
function bounce() {
if (curJackhammer == 10)
curJackhammer = 0;
else
++curJackhammer;
document.getElementsByTagName(
“img”)[0].src
= jackhammers[curJackhammer].src;
if (curJackhammer == 0)
direction = “up”;
else if (curJackhammer == 10)
direction = “down”;
document.getElementsByTagName(
“img”)[0].src
= jackhammers[curJackhammer];
}
function startBounce
function startBouncing() {
if (begin)
clearInterval(begin);
begin = setInterval(“bounce()”,90);
}
7. Save the document as Jackhammer.html in your Exercises folder for Chapter 10, and validate it with the W3C Markup Validation Service. Once the document is valid, open it in your Web browser and test the animation buttons.
We give our students 100% satisfaction with their assignments, which is one of the most important reasons students prefer us to other helpers. Our professional group and planners have more than ten years of rich experience. The only reason is that we have successfully helped more than 100000 students with their assignments on our inception days. Our expert group has more than 2200 professionals in different topics, and that is not all; we get more than 300 jobs every day more than 90% of the assignment get the conversion for payment.