Task 2 Learn and Practice How to Use documentwrite and HTML
Task #2: Learn and Practice How to Use: document.write() and
HTML image and link
Create three iframes1st frame:
Ø Use document.write()methods to generate three images:
Þ Image of your home in Canada
Þ Image of yourself
Þ Image of San Francisco
2nd frame:
Þ Usedocument.write()method to link to a Jupiter website
Þ Usedocument.write()methods to generate the following pattern:
$
$ $
$ $
$ $
$ $
$$$$$$$$$$$
$
$
$
Hint:
Special Characters in HTML
nonbreaking space
 
3rd frame:
Þ Write a simple program by using HTML and JavaScript that prompts the user to input the price of math book and test price of mini-tablet computer; after that you have to calculate the average of these two items (i.e. (pBook + pComputer) ÷ 2).
Þ Requirements:
v The data input must use theprompt() function.
Hint:
Ø parseFloat(…) ….. used to convert astring number into a numeric number.
Ø document.write(…) method to output the result.
Solution
Here the code will be look like
<!DOCTYPE html>
<html>
<body>
<script>
document.write(\"  $\");
document.write(\"<br>\");
document.write(\"$   $\");
document.write(\"<br>\");
document.write(\"$      $\");
And so on..
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<body>
<p>Sum the value</p>
<button onclick=\"myFunc()\">Try it</button>
<p id=\"demo\"></p>
<script>
function myFun() {
var p1 = prompt(\"Please enter book price\", 100);
var p2 = prompt(\"Please enter computer price\", 1000);
var p3 = p1 + p2 / 2
if (p3 != null) {
document.getElementById(\"demo\").innerHTML =
\"Average is \" + p3
}
}
</script>
</body>
</html>


