15.02.2013 Views

JavaScript Examples Bible - UserWorks Technologies

JavaScript Examples Bible - UserWorks Technologies

JavaScript Examples Bible - UserWorks Technologies

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 1 ✦ Generic HTML Element Objects (Chapter 15)<br />

Example<br />

If you have a sample document that contains XML and a namespace spec, you<br />

can use document.write() or alert() methods to view the value of the<br />

scopeName property. The syntax is<br />

document.all.elementID.scopeName<br />

scrollHeight<br />

scrollWidth<br />

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

Compatibility ✓ ✓ ✓<br />

Example<br />

Use The Evaluator (Chapter 13 in the <strong>JavaScript</strong> <strong>Bible</strong>) to experiment with these<br />

two properties of the TEXTAREA object, which displays the output of evaluations<br />

and property listings. To begin, enter the following into the bottom one-line text<br />

field to list the properties of the body object:<br />

document.body<br />

This displays a long list of properties for the body object. Now enter the following<br />

property expression in the top one-line text field to see the scrollHeight property<br />

of the output TEXTAREA when it holds the dozens of lines of property listings:<br />

document.all.output.scrollHeight<br />

The result, some number probably in the hundreds, is now displayed in the output<br />

TEXTAREA. This means that you can scroll the content of the output element<br />

vertically to reveal that number of pixels. Click the Evaluate button once more. The<br />

result, 13 or 14, is a measure of the scrollHeight property of the TEXTAREA that<br />

had only the previous result in it. The scrollable height of that content was only 13 or<br />

14 pixels, the height of the font in the TEXTAREA. The scrollWidth property of the<br />

output TEXTAREA is fixed by the width assigned to the element’s COLS attribute (as<br />

calculated by the browser to determine how wide to make the textarea on the page).<br />

scrollLeft<br />

scrollTop<br />

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

Compatibility ✓ ✓ ✓<br />

43<br />

elementObject.scrollLeft

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

Saved successfully!

Ooh no, something went wrong!