Closed Thread Icon

Preserved Topic: layer visibiltiy help (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=17708" title="Pages that link to Preserved Topic: layer visibiltiy help (Page 1 of 1)" rel="nofollow" >Preserved Topic: layer visibiltiy help <span class="small">(Page 1 of 1)</span>\

 
DL-44
Maniac (V) Inmate

From: under the bed
Insane since: Feb 2000

posted posted 04-26-2000 18:29

OK, I'm going out of my mind here (mainly because I don't know what I'm doing).
This is what I want to do -- I have 6 text layers occupying the same space. Onload, I want 1 to be visible and the other 5 hidden. I want to be able to click on buttons to the side, and for each button, make a certain layer visible and the other 5 hidden.
I have been using freebie scripts to accomplish other things, and have found some freebie scripts that do *almost* what I want to do, but not exactly.
Oh yeah, the text layers are the same wdth, but not the same height, so if they're stacked, they overlap.
Any help anyone? I would be grateful. <P>What care I how time advances? I am drinking Ale today. -- Edgar Allen Poe

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 04-26-2000 20:55

I assume you're using absolute positioning; thats what it sounds like at least. If the DIV tag has an ID="LayerName" then:<P>in IE:
document.all.LayerName.style.visibility = "hidden";
(or "visible")<P>in NN:
document.LayerName.visibility = "hide";
(or "show").<P>Is that what you're looking for?

Boudga
Maniac (V) Mad Scientist

From: Jacks raging bile duct....
Insane since: Mar 2000

posted posted 04-26-2000 20:59

How do you implement both IE and NN vis tags in the same script Slime?

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 04-26-2000 22:03

Well, there are a couple different ways to determine what browser they are using. One is the "navigator" property (capitalized or not? i dunno) navigator.appVersion, I beleive, contains the company name - search that string for "microsoft" or "netscape". I'm not quite so sure if that's the right property. This is not the method that I usually use.<P>The other way to do it, which I prefer, determines not only the browser but whether the browser is recent enough. Use this code:<P>var IE = (document.all)?true:false;
var NN = (document.layers)?true:false;<P>the ? operator is kind of weird. if the statement before it is true, then it returns the first value (in this case "true"). If not, it returns the second value. So, if the document.all property exists, it will be labeled as IE. If not, and the document.layers property exists, NN will be true.<P>So later in the code you can test for these variables.

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 04-27-2000 01:27

I have an example of this on my page (www.bitdamaged.com)<P>Its pretty much exactly what you want.
There are two main parts to this.<P>The first is a clear function:
function clear(){
var sections = new Array('who', 'past', 'current', 'contact', 'arrow');
for (i = 0; i < sections.length; i++){
eval(docObj + sections[i] + StyleObj + '.visibility = "hidden"');<P>What this does is when you click on a button it sets the visibility of all the elements in the array to hidden (I use mostly graphics but there could easily be text in these DIVs) also this code works in both browsers the docObj and StyleObj variables are set on page load with this code:<P>netscape = (document.layers) ? 1:0
goodIE = (document.all) ? 1:0
if (netscape) {
var docObj = "document.";
var StyleObj = ""; }
else if (goodIE) {
var docObj = "document.all.";
var StyleObj = ".style"; }<P>Okay you following so far? ;-) now we have this clear function but it's not used yet. we are going to use it in our "show" function:<P>function show(img){
focus();
clear();
eval(docObj + img + StyleObj + '.visibility = "visible"');
}
<P>This does a couple of things. The focus(); just make it so that in IE the button you clicked loses its dotted border.<P>Now the clear button turns everything off. and the last line turns on the image that corresponds to the link.<P>This is how I do it
<A HREF="#" onClick="show('who');">graphics/who.gif</a><P>Where 'who' is the name of the Div I want to show.<P>Okay??
Lemme know if it works. If you go to my site you'll see that the codee is a little more complicated. the reason is that (and this only works in IE) I wanted it to work that if people click on the link once it would go on and click it again and it would go off...
actually I just thought of a way to get this to work in both browsers <P>
"All right, brain, I don't like you and you don't like
me - so let's
just do this and I'll get back to killing you with
beer."
* Homer Simpson
<p>[This message has been edited by bitdamaged (edited 28-04-2000).]

DL-44
Maniac (V) Inmate

From: under the bed
Insane since: Feb 2000

posted posted 04-27-2000 06:25

Wow, cool. I haven't tried any of this yet, but thank you for the detailed responses! I will give some things a whirl and let you know what happens. <P>What care I how time advances? I am drinking Ale today. -- Edgar Allen Poe

DL-44
Maniac (V) Inmate

From: under the bed
Insane since: Feb 2000

posted posted 04-27-2000 07:38

SUCCESS!!!!!!!!!!
Thank you bitdamaged! I had to make a couple slight alterations (I was very happy to be able to identify a syntax error [a big step for me at this point]). The functionality is *exactly* what I wanted, and fit wonderfully with what i already had established. I really like the implementation of at your site as well -- nice smooth feel to everything.
Thanks a million! I'll be sure to give you a nice mention on my site when I finally finish it. : )<P>What care I how time advances? I am drinking Ale today. -- Edgar Allen Poe

DL-44
Maniac (V) Inmate

From: under the bed
Insane since: Feb 2000

posted posted 04-27-2000 07:58

BTW, thank you as well Slime. Your replies are always very informative -- scripting is *not* my strong point, I am barely starting to learn anything about in any tangible sense. The fact that I actually understand what you posted is a milestone for me... : )<P>What care I how time advances? I am drinking Ale today. -- Edgar Allen Poe

« BackwardsOnwards »

Show Forum Drop Down Menu