[Javascript] Could someone explain this to me.

Gary Histand ghistand at iwichita.com
Mon Jan 14 20:37:58 CST 2002


Javascripters:

I am an Organic Chemistry teacher trying to create an on-line tutorial for
my students. I have used Javascript in the past to do some minor things.
This is my first endeavor at a major undertaking and I am getting confused
early in the process. Perhaps some of you can help me.

I found the following code on-line. It allows for a box to pop-up when one
clicks a hyperlink. Below is the code, I understand it starts out
determining what browser is being used. Then the function showtip is where
the confusion comes in.

The first if statement: in plain english if NN6 or IE6 do the following.
It never says to show the div or to put text into the div or anything. What
is going on here?

The else if statement makes sense to me. If NN4 build the string and assign
to the box, put the box where in relation to where you clicked....

Then comes the function hidetip. It only says to hide for NN4. What happens
to NN6 and IE6?

Also this script only works for text that is in the <a></a> tag. It does not
work with an image as I have coded below. Why?

This is my first post so be gentle.

Thanks.

Gary Histand
Bethel College
North Newton, KS

<script >
<!--

if (!document.layers&&!document.all&&!document.getElementById)
event="test"
function showtip(current,e,text){

if (document.all||document.getElementById){
thetitle=text.split('<br>')
if (thetitle.length>1){
thetitles=''
for (i=0;i<thetitle.length;i++)
thetitles+=thetitle[i]
current.title=thetitles
}
else
current.title=text
}

else if (document.layers){
document.tooltip.document.write('<layer bgColor="white" style="border:1px
solid black;font-size:12px;">'+text+'</layer>')
document.tooltip.document.close()
document.tooltip.left=e.pageX+5
document.tooltip.top=e.pageY+5
document.tooltip.visibility="show"
}
}
function hidetip(){
if (document.layers)
document.tooltip.visibility="hidden"
}
//-->
</script>

<div id="tooltip" style="position:absolute;visibility:hidden"></div>

<a href="javascript:void(0)" onclick="showtip(this, event,'This is a
Williamson Ether Synthesis')" onMouseout="hidetip()">hint<img
src="hintbutton.gif" alt="" width="66" height="22" border="0"></a>







More information about the Javascript mailing list