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.

We could get into trouble if the value of the text fields aren't<br />

// numbers, so we assume that a non-integer value means zero.<br />

function computeSum()<br />

{<br />

}<br />

var n1 = parseInt(document.all("num1").value);<br />

if (!isFinite(n1))<br />

n1 = 0;<br />

var n2 = parseInt(document.all("num2").value);<br />

if (!isFinite(n2))<br />

n2 = 0;<br />

return n1 + n2;<br />

document.all("sum").setExpression("innerText", "computeSum()");<br />

// -->><br />

<br />

<br />

<br />

Many developers find the dynamic properties capability very exciting. It simplifies some aspects<br />

of page layout and can be used to implement all sorts of applications. <strong>The</strong> simple calculator<br />

capabilities hinted at in the previous example are just the tip of the iceberg.<br />

DHTML Behaviors<br />

Behaviors are aimed at moving complex DHTML code out of the page and into smaller,<br />

encapsulated, reusable units that serve as the basic building blocks for more complicated<br />

applications. Behaviors are a natural outgrowth of the scriptlet capabilities included as a part of<br />

Internet Explorer 4. <strong>The</strong> idea is to encapsulate specific functionality—for example, rollover<br />

image swapping or tooltip display—in an HTML Component (HTC) that can be bound to

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

Saved successfully!

Ooh no, something went wrong!