Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: now I don't see it, now I still don't see it! DIV problem in Netscape


Message #1 by "Goh Chye Kiang" <goh_chye_kiang@u...> on Tue, 25 Sep 2001 02:12:17
Although that code won't support Netscape 6 and other DOM-compliant
browsers...

Try this instead:

var ie4 = (navigator.appName.indexOf("Microsoft Internet Explorer") != -1 &&
parseInt(navigator.appVersion.substr(0, 1), 10) == 4)? true : false;
var ns4 = (navigator.appName.indexOf("Netscape") != -1 &&
parseInt(navigator.appVersion.substr(0, 1), 10) == 4)? true : false;

function ShowHideDiv(strDivId, bShow) {
	var oElm = (ns4) document.layers[strDivId] : (ie4)?
document.all[strDivId].style : document.getElementById(strDivId);
	oElm.visibility = (bShow)? "visible" : "hidden";
}


<a href="index.htm" onMouseOver="ShowHideDiv('DivID', true)"
onMouseOut="hide
('xxxx')">Link Text</a>

<div id="DivID" style="position:absolute; left:px; top:px; width:px;
padding-left:10px; padding-right:10px;
font-family:Arial,Helvetica,sans-serif; font-size:10pt; border:thin solid
#000000;  visibility:hidden;"> 
   <!--paste text here-->
	<p align="right"><a href="javascript:;"
onclick="ShowHideDiv('DivID', false); return
false;">Close</a></p>
</div> 



/Robert



-----Original Message-----
From: Andrew Thorne [mailto:AndrewT@C...] 
Sent: den 25 september 2001 14:32
To: javascript
Subject: [javascript] RE: now I don't see it, now I still don't see it! DIV
problem in Netscape


here is a cross browser Show and hide function that will work for you!


function ShowDiv(DivID) {  
      (document.all)? (document.all[DivID].style.visibility = 'visible') :
(document.layers[DivID].visibility = 'show');
      }

function HideDiv(DivID) {   // Generic function to hide a specific Div
      (document.all)? (document.all[DivID].style.visibility = 'hidden') :
(document.layers[DivID].visibility = 'hide');
      }

 <div id="DivID" style="position:absolute; left:px; top:px; width:px;
padding-left:10px; padding-right:10px;
font-family:Arial,Helvetica,sans-serif; font-size:10pt; border:thin solid
#000000;  visibility:hidden;"> 
   <!--paste text here-->

<p align="right"><a href="javascript:;" onclick="HideDiv('DivID'); return
false;">Close</a></p>
</div>  
   

"Of all the things I've lost, I miss my mind the most."  - Ozzy Osbourne 

Andrew Thorne (Quazi Evil) 
Web Developer 
ContentAlive      
Direct:  (xxx) xxx-xxxx  
General:  (xxx) xxx-xxxx
fax: (506) 457 - 9500 
toll free: 1- 888 - 794 - 8444 
" E - Learning Experienced"


-----Original Message-----
From: Goh Chye Kiang [mailto:goh_chye_kiang@u...]
Sent: Monday, September 24, 2001 11:12 PM
To: javascript
Subject: [javascript] now I don't see it, now I still don't see it! DIV
problem in Netscape


can anyone help with this chunk of code? I am trying to make the textarea 
appear/disappear in both IE and Netscape, but Netscape dun work as 
expected......wats the prob? some zindex property? 

TIA 

********************************************** 

<script type="text/javascript" language="JavaScript"><!-- 
function show(object) { 
if (document.layers && document.layers[object]) 
document.layers[object].visibility = 'visible'; 
else if (document.all) 
document.all[object].style.visibility = 'visible'; 
} 

function hide(object) { 
if (document.layers && document.layers[object]) 
document.layers[object].visibility = 'hidden'; 
else if (document.all) 
document.all[object].style.visibility = 'hidden'; 
} 
//--></script> 

<style type="text/css"><!-- 
.myLayersClass { position: absolute; visibility: hidden; } 
//--></style> 

<a href="index.htm" onMouseOver="show('xxxx')" onMouseOut="hide
('xxxx')">Link Text</a> 

<div id="xxxx" class="myLayersClass"> 
Put some text in this layer... 
<textarea name="mytext" cols="30" rows="3"></textarea> 
</div>

  Return to Index