spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / dhtml / column5
Developer News
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?

Logo

Dynamic Content in IE4:
changing the values of the new properties


Let's look at our quote again:

Saving Parts of the Page HTML

When the page you are reading was loading, in fact, just before the </BODY> tag, it encountered this script snippet:

Here, we assigned the value of quote.innerHTML to a variable so we can use it later. saveQuote now contains all the HTML enclosed by the BLOCKQUOTE start and end tags.

Assigning New Values (a live example)

In our SCRIPT we have defined five functions. Four of them assign string literals to properties when called, and the fifth restores the original look of the quote by assigning the value of saveQuote back to the element it was originally read from.

These functions are activated by clicking on buttons defined in the BODY:

Note the new <BUTTON> tag and its use. Simple and effective.

The example for IE4 Users

For IE4 WIN95 users, here's the code in action. Press the buttons to see the results live. Reset before repeating a feature. Remember two of the functions delete the element reference. A second attempt to access that element will generate an error. If you experiment and an error is generated, you will be asked by Explorer whether you want to contiunue using scripts on this page. CLICK YES!. Then RESET. No problem. If you click NO the script routines are lost.

It was the best of times, it was the worst of times, it was the age of wisdom, it was the age of foolishness...


The example for the Rest of Us

For those of you without IE, here is a table with the results of each click:

Button/
Function
The resulting HTML is...and the on-screen display is...
.innerText...it was the <B ID="goodTimes">&lt;I&gt;
grooviest&lt;/I&gt;</B> of times...
...it was the <I>grooviest</I> of times...
.outerText...it was the of times......it was the of times
.innerHTML...it was the <B ID="goodTimes"><BIG>
greatest<BIG></B> of times...
...it was the
greatest
of times...
.outerHTML...it was the <FONT COLOR='blue'>most horrible</FONT> of times......it was the most horrible of times...

Although we have used simple text-insertion HTML for our examples, the exact same techniques can be used to replace images, applets and controls. Any valid HTML can be inserted, regardless of length or content.

This same rule applies to the new methods, as well.


Produced by Peter Belesis and

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Rolling Out Your Own HTML Application Version Control · HTML 5: Client-side Storage · Working with Ajax Server Extensions
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Wi-Fi Product Watch, November 2009 · Chip Market Recovering From '08 Collapse · Low-Cost Tools to Kickstart Your New Business

All Rights Reserved. Legal Notices.
Created: 09/24/97
Revised: 09/28/97

URL: http://www.webreference.com/dhtml/column5/propChange.html