15.02.2013 Views

JavaScript Examples Bible - UserWorks Technologies

JavaScript Examples Bible - UserWorks Technologies

JavaScript Examples Bible - UserWorks Technologies

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

254<br />

document.write()<br />

<strong>JavaScript</strong> <strong>Examples</strong> <strong>Bible</strong>: The Essential Companion to <strong>JavaScript</strong> <strong>Bible</strong><br />

Listing 18-17: document.write() Example<br />

<br />

<br />

Document Write Controller<br />

<br />

function takePulse(form) {<br />

var msg = “On The Fly with “ + form.yourName.value +<br />

“”<br />

msg += “Good Day “ + form.yourName.value +<br />

“!”<br />

for (var i = 0; i < form.how.length; i++) {<br />

if (form.how[i].checked) {<br />

msg += form.how[i].value<br />

break<br />

}<br />

}<br />

msg += “Make it a great day!”<br />

parent.Frame2.document.write(msg)<br />

parent.Frame2.document.close()<br />

}<br />

function getTitle() {<br />

alert(“Lower frame document.title is now:” + parent.Frame2.document.title)<br />

}<br />

<br />

<br />

<br />

Fill in a name, and select how that person feels today. Then click “Write To<br />

Below”<br />

to see the results in the bottom frame.<br />

<br />

Enter your first name:<br />

How are you today? Swell<br />

<br />

Pretty Good<br />

<br />

So-So<br />

<br />

<br />

<br />

<br />

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!