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.

200<br />

IFRAME.src<br />

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

scrolling<br />

NN2 NN3 NN4 NN6 IE3/J1 IE3/J2 IE4 IE5 IE5.5<br />

Compatibility ✓ ✓ ✓ ✓<br />

Example<br />

The following toggleIFrameScroll() function accepts a string of the IFRAME<br />

element’s ID as a parameter and switches between on and off scroll bars in the<br />

IFRAME. The if condition checks whether the property is set to something other<br />

than no. This test allows the condition to evaluate to true if the property is set to<br />

either auto (the first time) or yes (as set by the function).<br />

function toggleFrameScroll(frameID) {<br />

// IE5 & NN6 version<br />

var theFrame = document.getElementById(frameID)<br />

// IE4+ version<br />

// var theFrame = document.all[frameID]<br />

if (theFrame.scrolling != “no”) {<br />

theFrame.scrolling = “no”<br />

} else {<br />

theFrame.scrolling = “yes”<br />

}<br />

}<br />

src<br />

NN2 NN3 NN4 NN6 IE3/J1 IE3/J2 IE4 IE5 IE5.5<br />

Compatibility ✓ ✓ ✓ ✓<br />

Example<br />

For best results, use fully formed URLs as value for the src property, as shown<br />

here:<br />

document.getElementById(“myIframe”).src = “http://www.dannyg.com”<br />

Relative URLs and javascript: pseudo-URLs also work most of the time.

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

Saved successfully!

Ooh no, something went wrong!