- basic scripting - |
Let's return to our technical defenition of dHTML:
So, then, the next question probably is: what's an object? Well, an object can be anything. It can be text, an image, a table, or any of those mixed in any order. This paragraph could be an object. Or, any picture could be an object. The next step in dHTML is assigning CSS properties to an object. Basically, by doing this you define what the object should look like. The height, width, position, color, etc. is defined. So how do you create an object to manipulate with dHTML? You use <DIV> and <SPAN> tags. Those two tags both do the same thing. They define a block of material, like some text or a picture as an object, and give that block of material a name. They'll both do the job. However, use a <SPAN> tag. They're a bit easier to use, and to follow along with. Here's a typical <SPAN> tag: <span id="bob" style="width: 20; height: 140; background: blue; font-family: arial; font-size: 40pt; position: relative; top: 0; left: 0;"> hey, this object is named bob </span> Looks long, I know. Notice how I named it "bob" by using id=. Also notice that I used lower-case letters instead of all capitals. Here's what that same tag creates:
<script language="JavaScript"> function proveIt() { if (document.all) { alert(bob); } else { alert(document.bob); } } //--> If you don't understand the script, that's fine. It will all be explained. This function when called up will have an alert. What does it say? To call up the function, I'll use a link. <a href="#" onClick="proveIt"> or <a href="javascript:proveIt()">. here's the working link In MIE 4.0+, the alert says "[object]". In Netscape Navigator, it alerts [object Layer]. Why? You'll find out in the next lesson. Also, for the script to work in Navigator, you must have a position defined on the object. If you have no clue what I just said, that's okay. You'll learn.
|