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!

Can I control visibility in Netscape?

Status
Not open for further replies.

Boblevien

Technical User
Nov 3, 2000
38
GB
I am trying to reproduce some DHTML (that works perfectly in IE) to work in Netscape. I’ve read various books but the suggested syntax doesn’t seem to work for me. First the IE version: (which creates an image of a closed envelope which, when clicked, changes to an open envelope and text is displayed)

<html>

<script Language=&quot;JavaScript&quot;>
// these are the images for toggleMessage()
var openEnv = new Image();
openEnv .src = &quot;images/envo.gif&quot;
var closeEnv = new Image();
closeEnv.src = &quot;images/envc.gif&quot;

function toggleMessage(N) {
if (document.all[(&quot;ID&quot; + N)].style.visibility == 'hidden')
{
document.all[(&quot;ID&quot; + N)].style.visibility = 'visible';
document[(&quot;icon&quot; + N)].src=openEnv.src;
}
else
{
document.all[(&quot;ID&quot; + N)].style.visibility = 'hidden';
document[(&quot;icon&quot; + N)].src=closeEnv.src;
}
}


</script>

<body>

<img border=&quot;0&quot; name=&quot;icon1&quot; src=&quot;images/envc.gif&quot; width=26 height=24 onClick=toggleMessage(1)>

<div Id=ID1 style=&quot;position: absolute; top: 24; left: 71; width: 135; height: 19; visibility=hidden&quot;>
This is the message
</div>

</body>

The following is “supposed” to produce the same effect in Netscape but not for me!

<html>

<script Language=&quot;JavaScript&quot;>
// these are the images for toggleMessage()
var openEnv = new Image();
openEnv .src = &quot;images/envo.gif&quot;
var closeEnv = new Image();
closeEnv.src = &quot;images/envc.gif&quot;

function toggleMessage() {
if (document.message1.visibility == 'hidden')
{
document.message1.visibility = 'visible';
document.icon1.src=openEnv.src;
}
else
{
document.message1.visibility = 'hidden';
document.icon1.src=closeEnv.src;
}
}
</script>

<body>

<img border=&quot;0&quot; name=&quot;icon1&quot; src=&quot;images/envc.gif&quot; width=26 height=24 onClick=toggleMessage()>

<div Id=&quot;message1&quot; style=&quot;position: absolute; top: 24; left: 71; width: 135; height: 19; visibility=hidden&quot;>
This is the message
</div>

</body>

</html>

Can anyone suggest where I might be going wrong? (I know that Netscape 4.x is dead in the water but I'm still getting over 15% Netscape users visiting this particular site).

Cheers,

Bob..
 
Dear Boblevien.
There may be other issues as well, but my inexperienced eye suggets that you try changing visibility=hidden/visible to visibility=hide/show for NS4.

There is a bit of a debate about whether NS will respond to hidden/visible. NS6.0 does, and I have also experienced NS4 doing so in some circumstances. Trying won't hurt and might help!

' luck.

 
Hi,

Thanks for that. I've just tried it but it doesn't appear to make any difference. Search me!

Thanks all the same.

Bob..
 
alt131 is right
but also, you don't refer to an element with document.all.its_name in ns, rather with document.layers.its_name (as long as it was ABSOLUTE positioned)
so the idea is to replace all document.all[(&quot;ID&quot; + N)].style.visibility = 'visible'; with document.layers[(&quot;ID&quot; + N)].style.visibility = 'show';



 
nope, but close iza. We will want to use:

document.layers.layername.propertywewanttoacess

instead of:

document.layers.layername.style.propertywewanttoacess

;-) jared@aauser.com
 
thank you jaredn :)
you save me almost every day ;-)
 
Thanks! That's been really helpful and I've got it working now.

However.....(isn't there always a 'however'?)

However, I now find that I really want to be using 'display' rather than 'visibility' - but once again that's not working in NS. NS appears to hide text if the style includes &quot;display:none&quot; but I can't get it to display it using the methods you've all shown me above. Any ideas?

Bob..
 
display is not properly supported (at all?) in NS4.X and lower jared@aauser.com
 
As I feared! Anyway, thanks for your advice, it's been a great help.

Bob..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top