11.12.2012 Views

JavaScript 2.0-The Complete Reference, Second ... - freecodingtutorial

JavaScript 2.0-The Complete Reference, Second ... - freecodingtutorial

JavaScript 2.0-The Complete Reference, Second ... - freecodingtutorial

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

Table 13-7: (X)HTML Elements Associated with DOM Objects<br />

(X)HTML<br />

Tag(s)<br />

DOM Object Properties Methods<br />

marginHeight,<br />

marginWidth,<br />

name, noResize,<br />

scrolling, src<br />

HTMLIframeElement align,<br />

frameBorder,<br />

height, longDesc,<br />

marginHeight,<br />

marginWidth,<br />

name, scrolling,<br />

src, width<br />

Manipulating an (X)HTML element and its associated attributes is very straightforward once the<br />

element is accessed using a method like document.getElementById( ) as shown here:<br />

Test Paragraph<br />

<br />

<br />

<br />

<br />

<br />

Adding (X)HTML elements is also straightforward using document.createElement() as shown<br />

in this next example, in which we follow the idea of the editor presented in Chapter 10. In this<br />

case, we allow the user to type in an arbitrary tag name and value and allow it to be added to<br />

the document. We apply a simple check to make sure that the user is not trying to add<br />

structural elements or add text content to an empty element, hinting at the type of logic one<br />

might start to employ to create a full-blown syntax-driven editor using the DOM.<br />

<br />

<br />

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

Saved successfully!

Ooh no, something went wrong!