DHTML Examples 437
DHTML
DHTML Examples
Web Design in a Nutshell, eMatter Edition
{
if ( navigator.appName == "Netscape" )
{
isNet4 = true;
}
if ( navigator.appName == "Microsoft Internet Explorer" )
{
isIE4 = true;
}
}
// End the browser detection script.
// Function "show" checks for browser type, then executes the
// appropriatecode to change the "hidden" object’s visibility
// from hidden to visible.
function show()
{
if (isNet4)
document.hidden.visibility = "visible";
}
if (isIE4)
{
document.all.hidden.style.visibility = "visible";
}
}
</script>
The HTML looks like this:
<BODY BGCOLOR="ffffff" TEXT="000000">
We want some text to appear after this text has been loaded.
<br>
<SPAN ID="hidden">This could be used to further define or give
background information for web content</SPAN>
<br>
<A HREF=javascript:show()>Click here to make text appear.</A>
</BODY>
</HTML>
The SPAN tag identifies some text ashidden. Thetag executes the
show() function, which makes any HTML between the tags visible.
Motion
Creating motion with DHTML is similar to making a style change—JavaScript
accesses the position attributes of a CSS object and changes them. Changing an
object’s position incrementally by one or two pixels creates the illusion of move-
ment. In this example, animated text will move onto the browser window from left
to right.