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="JavaScript">
// these are the images for toggleMessage()
var openEnv = new Image();
openEnv .src = "images/envo.gif"
var closeEnv = new Image();
closeEnv.src = "images/envc.gif"
function toggleMessage(N) {
if (document.all[("ID" + N)].style.visibility == 'hidden')
{
document.all[("ID" + N)].style.visibility = 'visible';
document[("icon" + N)].src=openEnv.src;
}
else
{
document.all[("ID" + N)].style.visibility = 'hidden';
document[("icon" + N)].src=closeEnv.src;
}
}
</script>
<body>
<img border="0" name="icon1" src="images/envc.gif" width=26 height=24 onClick=toggleMessage(1)>
<div Id=ID1 style="position: absolute; top: 24; left: 71; width: 135; height: 19; visibility=hidden">
This is the message
</div>
</body>
The following is “supposed” to produce the same effect in Netscape but not for me!
<html>
<script Language="JavaScript">
// these are the images for toggleMessage()
var openEnv = new Image();
openEnv .src = "images/envo.gif"
var closeEnv = new Image();
closeEnv.src = "images/envc.gif"
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="0" name="icon1" src="images/envc.gif" width=26 height=24 onClick=toggleMessage()>
<div Id="message1" style="position: absolute; top: 24; left: 71; width: 135; height: 19; visibility=hidden">
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..
<html>
<script Language="JavaScript">
// these are the images for toggleMessage()
var openEnv = new Image();
openEnv .src = "images/envo.gif"
var closeEnv = new Image();
closeEnv.src = "images/envc.gif"
function toggleMessage(N) {
if (document.all[("ID" + N)].style.visibility == 'hidden')
{
document.all[("ID" + N)].style.visibility = 'visible';
document[("icon" + N)].src=openEnv.src;
}
else
{
document.all[("ID" + N)].style.visibility = 'hidden';
document[("icon" + N)].src=closeEnv.src;
}
}
</script>
<body>
<img border="0" name="icon1" src="images/envc.gif" width=26 height=24 onClick=toggleMessage(1)>
<div Id=ID1 style="position: absolute; top: 24; left: 71; width: 135; height: 19; visibility=hidden">
This is the message
</div>
</body>
The following is “supposed” to produce the same effect in Netscape but not for me!
<html>
<script Language="JavaScript">
// these are the images for toggleMessage()
var openEnv = new Image();
openEnv .src = "images/envo.gif"
var closeEnv = new Image();
closeEnv.src = "images/envc.gif"
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="0" name="icon1" src="images/envc.gif" width=26 height=24 onClick=toggleMessage()>
<div Id="message1" style="position: absolute; top: 24; left: 71; width: 135; height: 19; visibility=hidden">
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..