JavaScript - JavaScript Basics
Week 4

These javascript capabilities use the DOM.

1. Write to the Browser Window (pg108)

document.write('<h1> Wlecome to the New and Improved JavaScript Class</h1><p>');

2. Use a variable (pg109)

planet = 17;
document.write('From planet no. ', planet,<br>);

3. Set color (pg112,113)
Note that JS is case Sensitive!

document.color = "orange";

document.write("The background color for this page is " + document.bgColor);

Expand that to include:

.fgColor
.linkColor

4. Document Title (pg116)

name = "Ben";
document.title = "Welcome to" + name + "'s House";
document.write(document.title);

You can also use document.URL or document.referrer

5. Open a New Browser Window (pg120)

window.open ("http://www.yahoo.com", "windowname","width=200, height=300,resizable=yes");

6. Close it (pg 122) Use testpage2.htm

<form>

<input type="button" value ="Close" onclick="window.close();"/>

7. Print the window's contents (pg 124)

<input type="button" value ="Print" onclick="window.print();"/>

8. Move a Window

<form name="form1">
<input type="button" value="Close" onClick="window.close();"/>
<input type="button" value="Print" onClick="window.print();"/>
<p>

horizontal: <input type="text" name="x" value="20"/>
vertical: <input type="text" name="y" value="50"/>
<input type="button" value="moveTo"
onClick="window.moveTo (document.form1.x.value,document.form1.y.value);"/>

</form>

9. Click here for Browser Shake!

10. Window Resize

11. Alert Box

12. Prompt Dialog Box

13. Confirm Dialog Box

14. Review of Images

15. Change Image with a Button