![]() |
|
|
netscape < internet explorer > dynamic content moving elements cross browser resources |
As I began taking on and learning IE 4's implementation of DHTML, and realized that there's a lot more to it than its NS counterpart. DHTML in IE does not rely on any one tag, but rather, new objects and properties that stem out of the usual HTML tags you're used to working with, such as <div> and <table>. It's a lot more powerful, but at the same time, and lot more complicated to grasp.
The style object of IE 4 <div id="adiv"></div> In your script, the syntax required to access the style object of "adiv" would look like this:
adiv.style Properties of the style objectThe style object contains many properties, and by manipulating these properties, you can alter the look of an element, dynamically. I'll show some of these properties now:
Here's a simple demonstration. The below text changes color when the mouse moves over it: Move your mouse here Here's the source code to the above text: <span id="sometext" onMouseover="sometext.style.color='red'" onMouseout="sometext.style.color='black'">Move your mouse here</span> Notice how I changed the text's color: sometext.style.color='red'
I first used the element's id to gain access to it, then, through the style object and finally the style's color property, I was able to easily change the color of the text on demand!
<img id="aimage" src="piza.gif" onMouseover="enlarge()" onMouseout="revertback()"> <script language="JavaScript1.2">function enlarge(){ aimage.style.pixelWidth=164 aimage.style.pixelHeight=202 } function revertback(){ aimage.style.pixelWidth=82 aimage.style.pixelHeight=101 } </script> Yes, I know its not exactly the most practical example in the world, but it does illustrate DHTML at work quite well. The image changes dimensions on demand, without the need to reload the document. That's something JavaScript alone can never do. |
![]() |
|