JavaScript Chapter 5




Skip to Chapter   1  2  3  4  5  6  7  8  9  10 

                                                              Chapter 5 -- DHTML






DHTML

DHTML stands for Dynamic Hypertext Mark-up Language
With DHTML you can manipulate objects on your web page by reffering to their names.
By knowing their true names you have total power over them, and can conjure them up when ever you wish (too much Wizard of Earth Sea).
In order to control the objects on your page, you must name them first... Well, it makes it a lot easier.
Here is an example of how you would name an image:
<img src="xmpl.jpg" name="example">
You can then create an alert box that shows you the value of src by using this snippet of code:
alert('The source is " + document.example.src);

Play around with this code and reopen(not just refresh) the page if you accidentally mess up and can't fix it.

the Prompt Function

The Prompt command brings up a small window for the user to enter one line of text in.
The code I used for the button was:
<input type="button" onclick="javascript:var temp = prompt('pretty groovy, huh?','write your response here');" value="See it in action!">
Whew!
The variable temp contains whatever the user types in the prompt box.
I'm glad you've hung on this long. JavaScript is quite difficult for someone to get in to, but now that you're into it things will run a lot more smoothly!
DHTML is pretty self-explainatory once you get the general idea of it.
Here are some of the things you can do with DHTML:
Create sort of cheesy, but fun, games.
Add a little interactive motion to your page (such as roll over images).
Create buttons that hop away from the mouse :)... set the hspace(or vspace) value of a button, and then change it on mouse over!
The sixth chapter will enlighten you in the ways of the form.
Conditions DHTML Forms