** URGENT DHTML DIV in net 4.7 **

I have a dropdown menu that uses a DIV tag in DHTML.  I need it to work in both netscape 4.7 and IE 5.0.  It works in IE, but not in Newtscape.  Here is the code, can somebody please tell me whay this dosent work in netscape?

If there is another way to get this to work, i dont care, as long as it works... maybe Show/Hide?

Thanks

Mtb007


<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- this is the code sorce that tells the rollovers to work-->
<script src="changeimage.js"></script>
<!-- this is where you name you different rollover files-->
<script src="nav.js"></script>
<!-- this is the code sorce that tells the rollovers to work-->
<script type="text/javascript">


<!-- All of this code below is so that Netscape can view the DIV tag-->
<!--
function toggle(theDiv){
      var elem = document.getElementById(theDiv);
      elem.style.display = (elem.style.display == "none")? "" : "none";
}
// -->
</script>
<style type="text/css">
<!--
img{
      border: 0px;
}
-->
</style>
<script language="JavaScript">
<!--
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
// -->
</script>


</head>
<body>
<!-- This code below HERE is what controls to position of the dropdown.

The position should be fairly close to where you need to place it.
You will probably nee to adjust it, and play with the numbers to get it exactaly where you need it.
To do that adjust the "left:____" & "top:____" numbers.  the numbers are setting the top left corner of the dropdown menu.  -->

<div id="Layer1" style="position:absolute; left:504px; top:173px; width:265px; height:277px; z-index:1"><span id="menuItems" style="width: 265px; display: none;">
<!-- This code HERE is that drop down menu with the rollovers -->
<a href="http://yoursite.com" onMouseOver="changeImages('sales', 'sales_on')" onMouseOut="changeImages('sales', 'sales_off')"onClick="toggle('menuItems');"><img name="sales" src="sales_off.gif" width="265" height="37" border="0"></a><br/>
      <a href="http://yoursite.com" onMouseOver="changeImages('borrower', 'borrower_on')" onMouseOut="changeImages('borrower', 'borrower_off')"onClick="toggle('menuItems');"><img name="borrower" src="borrower_off.gif" width="265" height="22" border="0"></a><br/>
      <a href="http://yoursite.com" onMouseOver="changeImages('agency', 'agency_on')" onMouseOut="changeImages('agency', 'agency_off')"onClick="toggle('menuItems');"><img name="agency" src="agency_off.gif" width="265" height="22" border="0"></a><br/>
      <a href="http://yoursite.com" onMouseOver="changeImages('agencyinfo', 'agencyinfo_on')" onMouseOut="changeImages('agencyinfo', 'agencyinfo_off')"onClick="toggle('menuItems');"><img name="agencyinfo" src="agencyinfo_off.gif" width="265" height="22" border="0"></a><br/>
      <a href="http://yoursite.com" onMouseOver="changeImages('billinginfo', 'billinginfo_on')" onMouseOut="changeImages('billinginfo', 'billinginfo_off')"onClick="toggle('menuItems');"><img name="billinginfo" src="billinginfo_off.gif" width="265" height="22" border="0"></a><br/>
      <a href="http://yoursite.com" onMouseOver="changeImages('entity', 'entity_on')" onMouseOut="changeImages('entity', 'entity_off')"onClick="toggle('menuItems');"><img name="entity" src="entity_off.gif" width="265" height="22" border="0"></a><br/>
      <a href="http://yoursite.com" onMouseOver="changeImages('pf', 'pf_on')" onMouseOut="changeImages('pf', 'pf_off')"onClick="toggle('menuItems');"><img name="pf" src="pf_off.gif" width="265" height="22" border="0"></a><br/>
      <a href="http://yoursite.com" onMouseOver="changeImages('salesreference', 'salesreference_on')" onMouseOut="changeImages('salesreference', 'salesreference_off')"onClick="toggle('menuItems');"><img name="salesreference" src="salesreference_off.gif" width="265" height="22" border="0"></a><br/>
      <a href="http://yoursite.com" onMouseOver="changeImages('spc', 'spc_on')" onMouseOut="changeImages('spc', 'spc_off')"onClick="toggle('menuItems');"><img name="spc" src="spc_off.gif" width="265" height="22" border="0"></a><br/>
      <a href="http://yoursite.com" onMouseOver="changeImages('salesterritory', 'salesterritory_on')" onMouseOut="changeImages('salesterritory', 'salesterritory_off')"onClick="toggle('menuItems');"><img name="salesterritory" src="salesterritory_off.gif" width="265" height="22" border="0"></a><br/>
<a href="http://yoursite.com" onMouseOver="changeImages('underwriting', 'underwriting_on')" onMouseOut="changeImages('underwriting', 'underwriting_off')"onClick="toggle('menuItems');"><img name="underwriting" src="underwriting_off.gif" width="265" height="37" border="0"></a><br/>
<a href="http://yoursite.com" onMouseOver="changeImages('parameter', 'parameter_on')" onMouseOut="changeImages('parameter', 'parameter_off')"onClick="toggle('menuItems');"><img name="parameter" src="parameter_off.gif" width="265" height="37" border="0"></a><br/>
</span>
<div style="width: 265px; height: 28px;" ><a href="#" onClick="toggle('menuItems');return false;"><img src="admin_nav.gif" width="265" height="28" border="0"></a></div>
</div>
This is where you start building the rest of the site.


</body>
</html>
LVL 1
mtb007Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

tatladyCommented:
i believe netscape didn't support dhtml until version 6.0.
0
mtb007Author Commented:
is there any way to do it in 4.7?
0
tatladyCommented:
not that I'm aware of. if you're writing asp or coldfusion or something like that, you could test for browser and use different verisons of the html depending on the browser accessing the file.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

jaysolomonCommented:
i do not know what the 2 *.js files do so i cannot help with them, but you can show hide div in 4.7

its a matter of testing for document.all,document.layers,document.getElementById

and also in NS4 you will have to ABSOLUTE position the div's
0
jaysolomonCommented:
here is an example of toggling divs in all browsers

<html>
<head>
<script type="text/javascript">
<!--
function switchDiv(divID,showIt)
{
 var divObj = (document.layers) ? document.layers[divID] :
(document.all) ?  document.all[divID] :  
document.getElementById(divID);

 if (arguments.length > 2)
 {
    if (document.layers)
    {
      divObj.document.open();
      divObj.document.write(arguments[2]);
      divObj.document.close();
    }
    else divObj.innerHTML = arguments[2];
 }
 var divStyle = (document.layers) ? divObj : divObj.style ;
 divStyle.visibility = (showIt) ? "visible" : "hidden" ;
}



//-->
</script>
</head>
<BODY onload="switchDiv('divFirst',true);switchDiv('divSecond',false);">
<a href="#" onClick="switchDiv('divFirst',1);switchDiv('divSecond',0);return false;">Section 1</a><br>
<a href="#" onClick="switchDiv('divFirst',0);switchDiv('divSecond',1);return false;">Section 2</a><br>
<form>
<input type="text" name='t'>
<input type="button" value="change div text" onclick="switchDiv('divFirst',true, this.form.t.value)">
</form><br>

<div id=divFirst style="position:absolute">
<p>This is my first div area</p>
</div>
<div id=divSecond style="position:absolute">
<p>This is my second div area</p>
</div>

</body>
</html>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jaysolomonCommented:
This

>>>function toggle(theDiv){
    var elem = document.getElementById(theDiv);
    elem.style.display = (elem.style.display == "none")? "" : "none";
}
<<<

Which looks like what i wrote, will work in NS6+ and IE5+
0
mtb007Author Commented:
The 2 *.js files are for the rollovers.  I have the DIV position set to ABSOLUTE.  Can you explain further about the document.all ... etc..? i dont understand..
0
jaysolomonCommented:
document.all = IE4

document.layers = NS4
 
document.getElementById = NS6+/IE5+/D O M

If you want this to work in NS4(which not alot of people use) then it can be done, you need to post your full source so we can then fix it the first time(hopefully).

In the upper code i do not see any div/layer name menuItems
0
mtb007Author Commented:
What i pasted above was everything,  except the js files. the only thing that they do is give the *.gif ID names to reference for the rollover.  
0
VincentPugliaCommented:
Hi,

 1) NN4 does not recognize the display property, so you must use visibility for it.
 2) by using 'visibility', a space will be held for the div; this means that your layout may be affected.
  3) regarding the code jay posted:

  var divObj = (document.layers) ? document.layers[divID] :
(document.all) ?  document.all[divID] :  
document.getElementById(divID);

  it is essentially saying the same as:

  if (document.layers)  // netscape 4.+
    var divObj =  document.layers[divID] ;
  else if (document.all) // IE4+ compatible browsers (IE5,IE6,AOL, etc)
    var divObj =  document.all[divID] :  
  else  // all other version 5+ browsers
     var divObj = document.getElementById(divID);

4) if the toggle function is the only one you are using, the following is how you would change it -- but note my final comment first:

function toggle(theDiv)
{
    var divObj = (document.layers) ? document.layers[divID] :
(document.all) ?  document.all[divID] :  document.getElementById(divID);

    var divStyle = (document.layers) ? divObj : divObj.style;

     if (document.layers)
        divStyle.visibility = (divStyle.visibility == 'hidden') ? 'visible' : 'hidden';
     else
        divStyle.display = (divStyle.display == "none")? "" : "none";
}

 5) Insofar as the dropdown menu itself:  You cannot have it.  NN4.7 chokes when it comes across the display:none and throws out all of the information between the span tags.  The only real way you can do it would be to write the divs/spans based upon the browser --

<script type='text/javascript' >
if (document.layers)
document.write("<span id='menuItems' style='....visibility:hidden; position:absolute'>")
else
document.write("<span id='menuItems' style='....display:none'>")
</script>
<a href.......
.......
<script type='text/javascript' >
document.write("</span>")
</script>

Or, you can redirect the user to a separate page.

In addition, because you have a span within a div, the code will actually look something like:

document.layers['Layer1'].document.layers['menuItems']....

this is because each layer within NN4 is a document within itself.

Vinny

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
HTML

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.