Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

<div> and javascript 1

Status
Not open for further replies.

shogun

Technical User
Jan 17, 2001
1
JP
I want to design a page say with four links on the left hand side when you mouse over each one a whole page appears (instead of having to clink a link to each page)
I know this uses the <div> tag and javascript, 'visible', 'hidden' etc but I'll be buggered if i can get it to work. Does anybody have any source code. It would be much appreciated, cheers
 
This can be good or bad, depending how large the stuff is you want to hide, since it all must be loaded at once.

<script language=&quot;JavaScript&quot;>
/* determine browser */
var NN = (document.layers)?true:false;
var IE = (document.all)?true:false;

function show(elemID){
if(NN){
eval('document.layers.'+ elemID + '.visibility= ' + &quot;'show'&quot;);
}
else if(IE){
document.all[elemID].style.visibility = &quot;visible&quot;
}
}

function hide(elemID){
if(NN){
eval('document.layers.'+ elemID + '.visibility= ' + &quot;'hide'&quot;);
}
else if(IE){
document.all[elemID].style.visibility = &quot;hidden&quot;
}

}
</script>


This should help...Remember in NN the divs need to be absolutely positioned before any of this stuff works. Try relative, I am not %100 sure of that.
When you call the function, pass it a string, which is the element's id.

...onClick=&quot;show('someElement')&quot;... &quot;Alright whatever man, I'll hook up the hair, but I aint touchin the ring...Cause I'm still a pla--yer&quot;
 
Actually, as long as you have them positioned,absolute or not, NN will read the style props.
Also
The reason we had to do these two different methods is that each browser stores it's style information in a different place, so to change anything we have to know where to look.

The eval() used here takes a string as an argument, and executes it as code. This is necessary since we send a string to the function.

I just thought you may want to know why I did some of those things. Also beware NN is very anal when it comes to coding, so I suggest developing with it, then converting to IE afterwards, makes life easier!

-Ben &quot;Alright whatever man, I'll hook up the hair, but I aint touchin the ring...Cause I'm still a pla--yer&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top