Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-02-2005, 10:06 PM   PM User | #1
dlg0351
Regular Coder

 
Join Date: Jan 2005
Posts: 140
Thanks: 0
Thanked 0 Times in 0 Posts
dlg0351 is an unknown quantity at this point
Question Layers Question

Can someone tell me why the "Welcome to..." appears so much further down on the page and not directly underneath the layers?

I assume it is because the top properties are adjusted so the changing line of text appears on the same line. But I thought anything you put inside a <div></div> with the visibility set to hidden would be the same as if it was not even there to begin with?

Here is the code:

<html>
<head>
<title></title>

<style>
<!--
.msg1{font-family:verdana;font-size:10px;color:red;font-weight:bold;}
.msg2{font-family:verdana;font-size:10px;color:blue;font-weight:bold;}
.msg3{font-family:verdana;font-size:10px;color:yellow;font-weight:bold;}
.msg4{font-family:verdana;font-size:10px;color:green;font-weight:bold;}
-->
</style>

<script language="Javascript">
<!--
function showLayer(msg)
{
var name = navigator.appName;
var vers = navigator.appVersion;

if((name == "Netscape") && (vers == "4.75 [en] (Windows NT 5.0; U)")){
}
else{
document.getElementById(msg).style.visibility = 'visible';
}
}

function hideLayer(msg)
{
var name = navigator.appName;
var vers = navigator.appVersion;

if((name == "Netscape") && (vers == "4.75 [en] (Windows NT 5.0; U)")){
}
else{
document.getElementById(msg).style.visibility = 'hidden';
}
}
//-->
</script>

</head>

<body>

<table border=0 cellpadding=0 cellspacing=0 width=540>
<tr>
<td><a href="#" onmouseover="showLayer('msg1');" onmouseout="hideLayer('msg1');"><img src="pic1.gif" width=135 height=30 border=0></a></td>

<td><a href="#" onmouseover="showLayer('msg2');" onmouseout="hideLayer('msg2');"><img src="pic2.gif" width=135 height=30 border=0></a></td>

<td><a href="#" onmouseover="showLayer('msg3');" onmouseout="hideLayer('msg3');"><img src="pic3.gif" width=135 height=30 border=0></a></td>

<td><a href="#" onmouseover="showLayer('msg4');" onmouseout="hideLayer('msg4');"><img src="pic4.gif" width=135 height=30 border=0></a></td>
</tr>

<tr>
<td colspan=4>
<div id="msg1" align="right" class="msg1" style="position:relative;left:0;top:0;width:540;height:20;visibility:hidden">Shop for thousands of online exclusives, and everyday items too!</div>

<div id="msg2" align="right" class="msg2" style="position:relative;left:0;top:-20;width:540;height:20;visibility:hidden">Online and in-store, printing, viewing and sharing photos is easier than ever.</div>

<div id="msg3" align="right" class="msg3" style="position:relative;left:0;top:-40;width:540;height:20;visibility:hidden">Fill prescriptions, get In-store Refills, check Rx prices, &amp; sign up for Refill Reminders.</div>

<div id="msg4" align="right" class="msg4" style="position:relative;left:0;top:-60;width:540;height:20;visibility:hidden">Get information and answers on a variety of health topics.</div>
</td>
</tr>
</table>

Welcome to...

</body>
</html>


Any help is much appreciated!
dlg0351 is offline   Reply With Quote
Old 02-02-2005, 10:19 PM   PM User | #2
rmedek
Senior Coder

 
Join Date: Nov 2003
Location: Minneapolis, MN
Posts: 2,879
Thanks: 2
Thanked 65 Times in 56 Posts
rmedek is on a distinguished road
Quote:
Originally Posted by PROWEBWORKS.NET
I thought anything you put inside a <div></div> with the visibility set to hidden would be the same as if it was not even there to begin with?
http://codingforums.com/showthread.php?t=51472
__________________
drums | web
rmedek is offline   Reply With Quote
Old 02-03-2005, 01:07 AM   PM User | #3
dlg0351
Regular Coder

 
Join Date: Jan 2005
Posts: 140
Thanks: 0
Thanked 0 Times in 0 Posts
dlg0351 is an unknown quantity at this point
I read the thread you were referring to and putting display:none; in the style tag does fix the text below the <div>'s but then when I mouseOver the images to show what is in the <div> tags, it doesn't work.

What can I do to fix this? As far as I know my coding is correct to show and hide the div's.

What am I missing here?
dlg0351 is offline   Reply With Quote
Old 02-03-2005, 01:25 AM   PM User | #4
_Aerospace_Eng_
Supreme Master coder!


 
_Aerospace_Eng_'s Avatar
 
Join Date: Dec 2004
Location: In a place far, far away...
Posts: 19,293
Thanks: 2
Thanked 1,044 Times in 1,020 Posts
_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light
try this
Code:
<html>
<head>
<title></title>

<style>
<!--
.msg1{font-family:verdana;font-size:10px;color:red;font-weight:bold;}
.msg2{font-family:verdana;font-size:10px;color:blue;font-weight:bold;}
.msg3{font-family:verdana;font-size:10px;color:yellow;font-weight:bold;}
.msg4{font-family:verdana;font-size:10px;color:green;font-weight:bold;}
#msg1{position:relative;left:0;top:0;width:540;height:20;display:none}
#msg2{position:relative;left:0;top:0;width:540;height:20;display:none}
#msg3{position:relative;left:0;top:0;width:540;height:20;display:none}
#msg4{position:relative;left:0;top:0;width:540;height:20;display:none}
-->
</style>

<script language="Javascript">
<!--
function showLayer(msg)
{
var name = navigator.appName;
var vers = navigator.appVersion;

if((name == "Netscape") && (vers == "4.75 [en] (Windows NT 5.0; U)")){
}
else{
document.getElementById(msg).style.display = 'inline';
}
}

function hideLayer(msg)
{
var name = navigator.appName;
var vers = navigator.appVersion; 

if((name == "Netscape") && (vers == "4.75 [en] (Windows NT 5.0; U)")){ 
}
else{
document.getElementById(msg).style.display = 'none';
}
}
//-->
</script>

</head>

<body>

<table border=0 cellpadding=0 cellspacing=0 width=540>
<tr>
<td><a href="#" onmouseover="showLayer('msg1');" onmouseout="hideLayer('msg1');"><img src="pic1.gif" width=135 height=30 border=0></a></td>

<td><a href="#" onmouseover="showLayer('msg2');" onmouseout="hideLayer('msg2');"><img src="pic2.gif" width=135 height=30 border=0></a></td>

<td><a href="#" onmouseover="showLayer('msg3');" onmouseout="hideLayer('msg3');"><img src="pic3.gif" width=135 height=30 border=0></a></td>

<td><a href="#" onmouseover="showLayer('msg4');" onmouseout="hideLayer('msg4');"><img src="pic4.gif" width=135 height=30 border=0></a></td>
</tr>

<tr>
<td colspan=4>
<div id="msg1" align="right" class="msg1">Shop for thousands of online exclusives, and everyday items too!</div>

<div id="msg2" align="right" class="msg2">Online and in-store, printing, viewing and sharing photos is easier than ever.</div>

<div id="msg3" align="right" class="msg3">Fill prescriptions, get In-store Refills, check Rx prices, &amp; sign up for Refill Reminders.</div>

<div id="msg4" align="right" class="msg4">Get information and answers on a variety of health topics.</div>
</td>
</tr>
</table>

Welcome to...

</body>
</html>
the negative numbers in the divs for positioning were making some of the messages appear over the images
_Aerospace_Eng_ is offline   Reply With Quote
Old 02-03-2005, 03:42 AM   PM User | #5
dlg0351
Regular Coder

 
Join Date: Jan 2005
Posts: 140
Thanks: 0
Thanked 0 Times in 0 Posts
dlg0351 is an unknown quantity at this point
Netscape layers/div in Netscape 4.75?

Hey AerospaceEng,

I made that changes that you said, the only modification I had to make was to enter some alignment and height properties for the <td> surrounding the <div>'s because it was moving the text below the <div> down onMouseover.

In the previous example I was ignoring the <div>'s if the browser/version were Netscape 4.75. Now I am trying to get this to work. I have pieced together so code that I have found on some other sites and examples, but am not having any luck.

I keep getting this error in Netscape 4.75: "document.layers[msg].style has no properties."

Here is my code, what can you make of it?

<html>
<head>
<title></title>

<style>
<!--

.msg1{font-family:verdana;font-size:10px;color:red;font-weight:bold;}
.msg2{font-family:verdana;font-size:10px;color:blue;font-weight:bold;}
.msg3{font-family:verdana;font-size:10px;color:yellow;font-weight:bold;}
.msg4{font-family:verdana;font-size:10px;color:green;font-weight:bold;}

#msg1{position:relative;left:0;top:0;width:540;height:20;display:none}
#msg2{position:relative;left:0;top:0;width:540;height:20;display:none}
#msg3{position:relative;left:0;top:0;width:540;height:20;display:none}
#msg4{position:relative;left:0;top:0;width:540;height:20;display:none}

-->
</style>

<script language="Javascript">
<!--
function showLayer(msg)
{
if(document.layers)
document.layers[msg].style.visibility = 'show';
else if(document.getElementById)
document.getElementById(msg).style.display = 'inline';
else if(document.all)
document.all.msg.style.display = 'inline';
}

function hideLayer(msg)
{
if(document.layers)
document.layers[msg].style.visibility = 'hide';
else if(document.getElementById)
document.getElementById(msg).style.display = 'none';
else if(document.all)
document.all.msg.style.display = 'none';
}
//-->
</script>

</head>

<body>

<table border=0 cellpadding=0 cellspacing=0 width=540>
<tr>
<td><a href="#" onmouseover="showLayer('msg1');" onmouseout="hideLayer('msg1');"><img src="pic1.gif" width=135 height=30 border=0></a></td>

<td><a href="#" onmouseover="showLayer('msg2');" onmouseout="hideLayer('msg2');"><img src="pic2.gif" width=135 height=30 border=0></a></td>

<td><a href="#" onmouseover="showLayer('msg3');" onmouseout="hideLayer('msg3');"><img src="pic3.gif" width=135 height=30 border=0></a></td>

<td><a href="#" onmouseover="showLayer('msg4');" onmouseout="hideLayer('msg4');"><img src="pic4.gif" width=135 height=30 border=0></a></td>
</tr>

<tr>
<td colspan=4 valign="top" align="right" height=20>
<layer name="msg1" class="msg1">
<div id="msg1" class="msg1">Shop for thousands of online exclusives, and everyday items too!</div>
</layer>

<layer name="msg2" class="msg2">
<div id="msg2" class="msg2">Online and in-store, printing, viewing and sharing photos is easier than ever.</div>
</layer>

<layer name="msg3" class="msg3">
<div id="msg3" class="msg3">Fill prescriptions, get In-store Refills, check Rx prices, and sign up for Refill Reminders.</div>
</layer>

<layer name="msg4" class="msg4">
<div id="msg4" class="msg4">Get information and answers on a variety of health topics.</div>
</layer>
</td>
</tr>
</table>

Welcome to...

</body>
</html>

I appreciate the help!
dlg0351 is offline   Reply With Quote
Old 02-03-2005, 04:19 AM   PM User | #6
_Aerospace_Eng_
Supreme Master coder!


 
_Aerospace_Eng_'s Avatar
 
Join Date: Dec 2004
Location: In a place far, far away...
Posts: 19,293
Thanks: 2
Thanked 1,044 Times in 1,020 Posts
_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light
hmm im not sure i dont have 4.5 i would think that it may have to be getElementById('msg'), recognizes what to do in netscape 7.2 sorry i can't be of more help
_Aerospace_Eng_ is offline   Reply With Quote
Old 02-03-2005, 04:23 AM   PM User | #7
dlg0351
Regular Coder

 
Join Date: Jan 2005
Posts: 140
Thanks: 0
Thanked 0 Times in 0 Posts
dlg0351 is an unknown quantity at this point
Netscape

Yeah, Netscape 4.75 does not recognize getElementById. I wish it were that simple. I have seen layers done in older browsers so I know it can be done. UGH!!!
dlg0351 is offline   Reply With Quote
Old 02-03-2005, 05:05 AM   PM User | #8
glenngv
Supreme Master coder!


 
glenngv's Avatar
 
Join Date: Jun 2002
Location: Los Angeles, CA Original Location: Philippines
Posts: 10,241
Thanks: 0
Thanked 112 Times in 111 Posts
glenngv will become famous soon enough
Change:

document.layers[msg].style.visibility

to:

document.layers[msg].visibility

NS4 doesn't have style (literally and figuratively )
__________________
Glenn
_____________________________________________
Play Tower of Hanoi Android app (Ad-FREE!)
Play Tower of Hanoi Android app (FREE!)
Go to Tower of Hanoi Leaderboard
Play Tower of Hanoi Facebook app
glenngv is offline   Reply With Quote
Old 02-03-2005, 12:22 PM   PM User | #9
dlg0351
Regular Coder

 
Join Date: Jan 2005
Posts: 140
Thanks: 0
Thanked 0 Times in 0 Posts
dlg0351 is an unknown quantity at this point
Ok, I changed it to document.layers[msg].visibility = 'show'; and I don't get an error, but it does not show the hidden layers, any more suggestions?
dlg0351 is offline   Reply With Quote
Old 02-03-2005, 12:51 PM   PM User | #10
rmedek
Senior Coder

 
Join Date: Nov 2003
Location: Minneapolis, MN
Posts: 2,879
Thanks: 2
Thanked 65 Times in 56 Posts
rmedek is on a distinguished road
Please let it be known that I have no idea how to code Javascript.

Code:
<html>
<head>
<title></title>

<style>
<!--
.msg1{font-family:verdana;font-size:10px;color:red;font-weight:bold;}
.msg2{font-family:verdana;font-size:10px;color:blue;font-weight:bold;}
.msg3{font-family:verdana;font-size:10px;color:yellow;font-weight:bold;}
.msg4{font-family:verdana;font-size:10px;color:green;font-weight:bold;}
-->
</style>

<script language="Javascript">
<!--
function showLayer(msg)
{
if(document.layers)
document.layers[msg].display = 'show';
else if(document.getElementById)
document.getElementById(msg).style.display = 'inline';
else if(document.all)
document.all.msg.display = 'inline';
}

function hideLayer(msg)
{
if(document.layers)
document.layers[msg].display = 'hide';
else if(document.getElementById)
document.getElementById(msg).style.display = 'none';
else if(document.all)
document.all.msg.display = 'none';
}
//-->
</script>


</head>

<body>

<table border=0 cellpadding=0 cellspacing=0 width=540>
<tr>
<td><a href="#" onmouseover="showLayer('msg1');" onmouseout="hideLayer('msg1');"><img src="pic1.gif" width=135 height=30 border=0></a></td>

<td><a href="#" onmouseover="showLayer('msg2');" onmouseout="hideLayer('msg2');"><img src="pic2.gif" width=135 height=30 border=0></a></td>

<td><a href="#" onmouseover="showLayer('msg3');" onmouseout="hideLayer('msg3');"><img src="pic3.gif" width=135 height=30 border=0></a></td>

<td><a href="#" onmouseover="showLayer('msg4');" onmouseout="hideLayer('msg4');"><img src="pic4.gif" width=135 height=30 border=0></a></td>
</tr>

<tr>
<td colspan=4 height="20px" align="right">
<div id="msg1" class="msg1" style="width:540;height:20;display: none;">Shop for thousands of online exclusives, and everyday items too!</div>

<div id="msg2" class="msg2" style="width:540;height:20;display: none;">Online and in-store, printing, viewing and sharing photos is easier than ever.</div>

<div id="msg3" class="msg3" style="width:540;height:20;display: none;">Fill prescriptions, get In-store Refills, check Rx prices, &amp; sign up for Refill Reminders.</div>

<div id="msg4" class="msg4" style="width:540;height:20;display: none;">Get information and answers on a variety of health topics.</div>
</td>
</tr>
</table>

Welcome to...

</body>
</html>
Copy, paste, test.
__________________
drums | web
rmedek is offline   Reply With Quote
Old 02-03-2005, 05:18 PM   PM User | #11
dlg0351
Regular Coder

 
Join Date: Jan 2005
Posts: 140
Thanks: 0
Thanked 0 Times in 0 Posts
dlg0351 is an unknown quantity at this point
Question

It didn't work, I got this error in Netscape 4.75:

document.layers[msg] has no properties.
dlg0351 is offline   Reply With Quote
Old 02-03-2005, 09:37 PM   PM User | #12
rmedek
Senior Coder

 
Join Date: Nov 2003
Location: Minneapolis, MN
Posts: 2,879
Thanks: 2
Thanked 65 Times in 56 Posts
rmedek is on a distinguished road
What are you testing on, a Commodore 64?

If your core audience uses Netscape 4.75, then you shouldn't be using such tricky things as Javascript, CSS, or HTML. Come on, man, seriously.
__________________
drums | web
rmedek is offline   Reply With Quote
Old 02-03-2005, 09:45 PM   PM User | #13
dlg0351
Regular Coder

 
Join Date: Jan 2005
Posts: 140
Thanks: 0
Thanked 0 Times in 0 Posts
dlg0351 is an unknown quantity at this point
HAHA! No but I wouldn't mind having my Commodore back, man the fun I had with Basic, haha!

Hey man I hear ya, but I know it can be done and I am determined to get it to work.
dlg0351 is offline   Reply With Quote
Old 02-08-2005, 08:33 AM   PM User | #14
Kor
Red Devil Mod


 
Kor's Avatar
 
Join Date: Apr 2003
Location: Bucharest, ROMANIA
Posts: 8,478
Thanks: 58
Thanked 379 Times in 375 Posts
Kor has a spectacular aura aboutKor has a spectacular aura about
NS4.7 should use the same display none/inline as the modern browsers. Don't confound with visibility which, indeed, has different values hide/show.

But NS4 needs a position to get display at work. Unfortunately, NS4 does not accept the relative postioning, thus you must use

<layer>
<ylayer>
...
</ylayer>
<layer>

Type of HTML coding to mime a relative postion. Furthermore, that means you need tow different CSS classes (for NS4 and for the rest)
__________________
KOR
Offshore programming
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
Kor is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:55 AM.


Advertisement
Log in to turn off these ads.