- basic scripting -

       the [object]
.   .   .

Let's return to our technical defenition of dHTML:

Changing CSS properties of an object through JavaScript.

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:

hey, this object is named bob



If you've worked with CSS, you should know how this works. If you need a bit more help, you can find out more about it on this website. So now, on this page, there's an object called "bob". If I use some JavaScript, I can prove that there's an object named "bob". Here's the script.

<script language="JavaScript">
<!--

function proveIt() {

if (document.all) { alert(bob); } else { alert(document.bob); }

}

//-->
</script>

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.

next >>

.   .   .

  1. Introduction
  2. What, Exactly, is it?
  3. The [object]
  4. Detecting Browsers
  5. Accessing Properties
  6. Making a Script
  7. Making the Script in Netscape
  8. What to Change?
  9. Creating a Menu
  10. Scripting the Menu
  11. The Netscape Menu
  12. Last Words