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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

NN4x Hide/show

Status
Not open for further replies.

alt131

Technical User
Dec 31, 2000
17
NZ
New to all this, so coding is probably a bit rough, but help with the concept would be appreciated. Am trying to set up a page where a click will increase the size of one layer and hide the others. A click reverses that. Works (written diferently) in NS6.0 and IE and the functions (resizeTo and moveTo) and hide/show work in NS4 until combined. Then the layers refuse to hide/show! This is the code less the script tags and the actual layers (which are in the body).

function maximise(width,height,x,y){
document.content.resizeTo(800,1000);
document.content.moveTo(45,0);
document.title.visibility="hide";
document.content2.visibility="hide";
document.menu.visibility="hide";
document.blank.visibility="hide";
document.maxDiv.visibility="show";
document.minDiv.visibility="show";
document.navy1.visibility="show";
document.yellow.visibility="show";
document.navy2.visibility="show";
document.red2.visibility="show";
}


function minimise(width,height,x,y){
document.content.resizeTo(600,300);
document.content.moveTo(140,190);
document.title.visibility="show";
document.content2.visibility="show";
document.menu.visibility="show";
document.blank.visibility="show";
document.maxDiv.visibility="hide";
document.minDiv.visibility="hide";
document.navy1.visibility="hide";
document.yellow.visibility="hide";
document.navy2.visibility="hide";
document.red2.visibility="hide";
}

Have tried document.layers.(layername)=hide/show.
Have tried styling visibility in the layer tag as well (that works via style sheet in IE) but in NS4 the visibility won't toggle if I do that. Have also tried ilayers - no help, and also divs/spans for the containers that don't move, just need to hide/show - and they just glare at me!

Hide/show works until I combine it with the move/resize function ..... possible reasons?

Any ideas would be great!!
 
So the functions you have given here are the ones that don't work?

-Ben "Alright whatever man, I'll hook up the hair, but I aint touchin the ring...Cause I'm still a pla--yer"
 
Thats right - (less the script tags). If the solution is obvious ... its not to me - be grateful for a simple explanation.

Also tried seperating the hide/show function from the move/resize function, then calling them both from the same onClick event. Didn't work, however have problems with the syntax of events so my code could have been the cause. If you think that would be a simple way to sort the problem is there any possibility of a sample that I could try?

Ideas really appreciated
 
in netscape, to hide a layer, you need to do:
document.layers[layername].visibility = "hidden";
in ie, to hide a layer, you need to do:
document.all[layername].style.visibility = "hidden";

to show a layer, just change "hidden" to "visible"

example: document.layers['navy1'].visibility = "hidden";

by the way, I would suggest using a function that looks something like this:

function showLayer(sLayer, bIsVisible) {
var setting = "visible";
if (!bIsVisible) {
setting = "hidden";
}
if (document.layers) {
// netscape
document.layers[sLayer].visibility = setting;
} else {
// IE
document.all[sLayer].style.visibility = setting;
}
}

example: showLayer('menu', true); //shows the layer ray
rheindl@bju.edu

 
"in netscape, to hide a layer, you need to do:
document.layers[layername].visibility = "hidden";"

this is incorrect the proper syntax to hide/show a layer in netscape 4.x is:
document.layers[layername].visibility = "hide";
document.layers[layername].visibility = "show";

jared@aauser.com
 
jaredn, I don't think ie recognizes "show" and "hide, but netscape does recognize "visible" and "hidden", so to make things easier in the function, I just use the same for both. Is this really "improper"? ray
rheindl@bju.edu

 
really? oops, im an idiot... :eek:)

I'll test that and come back! jared@aauser.com
 
Thanks guys, like I said, have tried document.layers[layername].visibility="hide"/"show". It doesn't work in the function I have written. I have an IE function that works and will keep the versions seperate for other reasons at this stage.

On the hide/hidden and show/visible. Don't want to get into this here but I can assure you that BOTH work. Reading the the NS developer material says they shouldn't but I can report that they do 'cos I have seen it.

The suggestions made deal with the hide/show issue. Like I said, can hide/show without difficulty (using this, and all the other variations the Netscape docs say will work).

As stated, the problem arises when I try to hide/show and move/resize at the same time. Would really appreciate ideas (that I have not already tried) about how to fix that problem.
 
don't have time to test it myself, but you may want to try using a setTimeout to call the second function that moves/resizes it. I'm sure there's a better way, but I'm not a NS man. ;o) jared@aauser.com
 
obviously, you aren't hide/show without difficulty, so why don't you go ahead and try to use the code I posted. ie and netscape are very picky about the way you reference layers.

also, why do you have document.content.resizeTo? are you trying to resize the window, in that case it should be window.resizeTo. My dom reference doesn't list content under document. ray
rheindl@bju.edu

 
I did try the suggested script - with much enthusiasm and high hopes because it looked like a really simple way to make the same script do for IE and NS. (Other ways I have seen and tried were much more complicated so this was a very exciting suggestion.) Unfortunately I couldn't make it work at all.

content is the name of a layer. I have used that name for IE and NS6 for which this concept is currently working. It also works in NS4x in both the move/resize and hide/show until the two functions are called together so am not thinking the name is causing probs. But for the record, I did try changing that as well - with no success.

Jaredn, am still trying to figure the set timeout thing and will let you know how that goes.
 
just so you know setTimeout works like this:

setTimeout("someFunc()",somemilliseconds) jared@aauser.com
 
Jaredn, thanks for the post - stored it away for the future.
I also asked this question at another site, and someone had a fiddle and produced a script that works. Two things they noted - document.title is netscapes way of accessing the title bar so that name was changed, plus they commented out some lines in the script and a tag in the body.

If you are interested in how the person made it work, head to Firing in NN4x in a few days. I have to work with a couple of other things, but it should be up by then.

Thanks for the sugestions.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top