Departments
 Info
   Home Page
   Articles
   Software Goodies

 Explanations
   How do they do that?
   The Web in Focus

 Resources
   Web Site Stuff
   Tech Books
   E-Books
   Tech Toys
   Web Hosting
   Links

 Women
   Opinion
   Tech Women
   Women's Studies

 Tech News
   Computer Security
   Databases
   Java
   Linux
   MP3
   PC Software
   Robotics
   Site Owner
   Tech Latest
   Web Development
   XML

 Spread the Word
   Newsletter
   Recommend this Page

 Site Info
   Legal Disclaimer
   Privacy
   Contact

 Lighter Side
   Crazy for Life
   crazy for romance
   Crazy for Kitties
   Crazy for Dogs
   Crazy for Cows

Copyright 2000-2001, hertechnology.com

 
The Web in Focus
Popup Text

Putting It Together, Continued

So, I had to make the DIV empty originally and write the table and the text into it when div_over was called. The browsers have some different syntax for how you write into an element. With NN, you have to open the document if it is a DIV you are writing to. With IE, you assign to the object's innerHTML property, thusly:

if (NN) {
  with (document.div1.document) {
    open();
    write(div_str);
    close();
  }
} else {
  div1.innerHTML = div_str;
}

As you will see shortly, div_str contains the HTML text to write into the DIV, namely a big string with the entire TABLE.

A couple of other items to mention. 1) I arbitrarily have one function that both makes the DIV visible and makes the DIV hidden depending upon whether you ask it to turn the DIV on or not. I could also have had two separate functions, div_on and div_off. It doesn't really matter.

2) There is also a trick that allows you to refer to the particular object you want to work with in a variable and use eval to turn it into a real object. For example, if I wanted to use div_over to work with a DIV2 object, I could. I pass in the number of the DIV I want to work with, and use eval to turn it into the right name.

if (IE) {
  whichEl = eval("document.all.div" + which + ".style");
} else {
  whichEl = eval("document.div" + which);
}

which is the name of the variable that signifies which DIV to use. In this example, which is always 1. (And, in order to work properly with multiple DIVs I would need other div_str's so I could write out different text in each box.)

3) I decided that having the box pop up every time you moved the cursor over the logo was annoying. So I use a little variable called div_seen to control whether or not to show the box. As soon as you see it once, I set div_seen to true, then use that to decide whether or not to show the box.

Page 5

Tech Books

Tech Toys

More News

  Want to bookmark this site? Press Control-D. (Hold down the control key and the letter D at the same time.)