150Part IIIDocument Objects ReferenceAnother desire is to have (Web and email hosting)

150Part IIIDocument Objects ReferenceAnother desire is to have JavaScript substitute document content when the browser isJavaScript-enabled. Only in IE4+ and W3C DOM-compatible browsers can a script replaceregular HTML with scripted content. If you develop content that must be backward compat- ible with older browsers, remember that all HTML in a document appears in the browserwindow, while scripted content can be additive only. You can use this additive scripting to create unusual effects when displaying different linksand (with a caveat) body text for scriptable and nonscriptable browsers. Listing 13-2 shows ashort document that uses HTML comment symbols to trick nonscriptable browsers into dis- playing a link to Netscape s Web site and two lines of text. A scriptable browser takes advan- tage of a behavior that allows only the nearest tag to be associated with a closing tag. Therefore, the Microsoft link isn t rendered at all, but the link to my Web site is. For thebody text, the script assigns the same text color to a segment of HTML body text as the docu- ment s background. While the colored text is camouflaged in a scriptable browser (and someother text written to the document), the hidden text remains invisible in the document. HTML fans frown upon this kind of element spoofing, which will likely run afoul of HTML val- idators. However, it can be fun to play with. Listing 13-2:Rendering Different Content for Scriptable andNonscriptable Browsers Where?


If you can read this, JavaScript is not available.
Here s some stuff afterward. Scripting for different browsersA number of solutions exist for accommodating different client browsers because the spe- cific compatibility need might be as simple as letting a link navigate to a scripted page for

Leave a Reply