Forum Moderators: open

Message Too Old, No Replies

Expandable menu: trying to make it work with IE and Netscape

I have div tags inside table elements. i read that I can not do that.

         

marknhu

7:43 pm on Jul 2, 2002 (gmt 0)



In IE, the menu is displayed correctly inside the table cell. However, in Netscape the image in the cell moves up to the left top corner. How can I get Netscape to position the image in the correct place?

Here is my code:

<table border="0" cellpadding="0" cellspacing="0">
<tr><td><img src="Mainimage/d_a.gif" width="124" height="76" alt="" border="0"></td></tr>
<tr>
<td class="leftside" width="0" height="10" bgcolor="#DDDFD8">

<DIV ID="elOneParent" class="parent"><A
HREF="#" onClick="expandIt('elOne'); return false"><img border="0" width="124" src="menu/overview.gif" alt="Overview"></A>
</DIV>

<DIV ID="elOneChild" CLASS="child"><a class="menu" href="review_process.html#over">Overview</a> <br><a class="menu" href="review_process.html#steps">Steps in the PMA Process</a> <br><a class="menu" href="review_process.html#collab">Early Collaboration</a> <br><a class="menu" href="review_process.html#fda_action_pma">FDA Action on PMAs</a>
</DIV>

<a href="import_export.html" ><img src="menu/import_export.gif" border="0" Name="HEAD15" alt="Import/Export"></a><a href="frequently_asked.html" ><img src="menu/faq.gif" border="0" Name="HEAD16" alt="Frequently Asked Questions"></a><a href="regulations.html" ><img src="menu/regulations.gif" border="0" Name="HEAD17" alt="Regulations"></a><a href="guidance_documents.html" ><img src="menu/guidance_documents.gif" border="0" Name="HEAD18" alt="Guidance Documents"></a></td>
</tr>
</table>

----------------------------
Here is the js file:

NS4 = (document.layers) ? 1 : 0;
IE4 = (document.all) ? 1 : 0;
ver4 = (NS4 ¦¦ IE4) ? 1 : 0;

if (ver4) {
with (document) {
write("<STYLE TYPE='text/css'>");
if (NS4) {
write(".parent {position:absolute; visibility:visible}");
write(".child {position:absolute; visibility:visible}");
write(".regular {position:absolute; visibility:visible}")
}
else {
write(".child {display:none}")
}
write("</STYLE>");
}
}

isExpanded = false;

function getIndex(el) {
ind = null;
for (i=0; i<document.layers.length; i++) {
whichEl = document.layers[i];
if (whichEl.id == el) {
ind = i;
break;
}
}
return ind;
}

function arrange() {
nextY = document.layers[firstInd].pageY + document.layers[firstInd].document.height;
for (i=firstInd+1; i<document.layers.length; i++) {
whichEl = document.layers[i];
if (whichEl.visibility != "hide") {
whichEl.pageY = nextY;
nextY += whichEl.document.height;
}
}
}

function initIt(){
if (!ver4) return;
if (NS4) {
for (i=0; i<document.layers.length; i++) {
whichEl = document.layers[i];
if (whichEl.id.indexOf("Child") != -1) whichEl.visibility = "hide";
}
arrange();
}
else {
divColl = document.all.tags("DIV");
for (i=0; i<divColl.length; i++) {
whichEl = divColl(i);
if (whichEl.className == "child") whichEl.style.display = "none";
}
}
}

function expandIt(el) {
if (!ver4) return;
if (IE4) {
whichEl = eval(el + "Child");
whichIm = event.srcElement;
if (whichEl.style.display == "none") {
whichEl.style.display = "block";
whichIm.src = "menu/overview.gif";
}
else {
whichEl.style.display = "none";
whichIm.src = "menu/overview.gif";
}
}

else {

whichEl = eval("document." + el + "Child");
whichIm = eval("document." + el + "Parent.document.images['imEx']");

if (whichEl.visibility == "hide") {
whichEl.visibility = "show";
whichIm.src = "menu/overview.gif";
}
else {
whichEl.visibility = "hide";
whichIm.src = "menu/overview.gif";
}
arrange();
}
}

function expandAll() {
if (!ver4) return;
newSrc = (isExpanded) ? "menu/overview.gif" : "menu/overview.gif";

if (NS4) {
document.images["imEx"].src = newSrc;
for (i=firstInd; i<document.layers.length; i++) {
whichEl = document.layers[i];
if (whichEl.id.indexOf("Parent") != -1) {
whichEl.document.images["imEx"].src = newSrc;
}
if (whichEl.id.indexOf("Child") != -1) {
whichEl.visibility = (isExpanded) ? "hide" : "show";
}
}

arrange();
if (isExpanded) scrollTo(0,document.layers[firstInd].pageY);
}
else {
divColl = document.all.tags("DIV");
for (i=0; i<divColl.length; i++) {
if (divColl(i).className == "child") {
divColl(i).style.display = (isExpanded) ? "none" : "block";
}
}
imColl = document.images.item("imEx");
for (i=0; i<imColl.length; i++) {
imColl(i).src = newSrc;
}
}

isExpanded = !isExpanded;
}

onload = initIt;

papabaer

1:02 am on Jul 3, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hello marknhu, welcome to Webmaster World!

NN4 & DHTML can be a challenge. Let's see if someone has had a similar experience and can offer a solution.