RexxCrow
07-28-2006, 05:41 AM
I just pretty much copied this code w/ a few mods to is from one of my JS books to convert my CSS menu to JS as I was not successful with making it fully operational in CSS. The probs with this are:
#1 In IE is acts funny swapping from block to none as you move from one button to the next, Firefox it works like a champ.
#2 the second is that is does nto collapse the menus upon loading only after you mouse over them. (Would this need a onload or eventlistener to solve this issue?)
I believe I have everything in order and have failed to see what I am missing, any assistance/advice would be great! thx. I am actually using a total of 9 sections but shortened it down to 4 for ease of viewing.
<HTML><HEAD><BASE target="menu"><script language="JavaScript" type="text/JavaScript"><!--
(document.getElementById ? DOMCapable = true : DOMCapable = false);
function conceal(menuPos) {
if (DOMCapable) {
var setMenu=document.getElementById(menuPos+"poslect");
setMenu.style.display='none';
}
}
function display(menuPos) {
if (DOMCapable) {
var setMenu=document.getElementById(menuPos+"poslect");
setMenu.style.display='block';
}
}
//--></script><STYLE TYPE="text/css"><!--
BODY {background-color: #778899;}
#setup {position: absolute; top: 10px; left: 10px; border-color: #B0C4DE; border-style: inset; border-width: 5px; font-family: Arial; font-size: 12px; text-align: center;}
.menu a {white-space: nowrap; display: block; text-decoration: none; color: #F0FFFF; border-color: #B0C4DE; border-style: outset; border-width: 4px; padding: 2px 10px;}
.menu a:hover {background-color: #B0C4DE; color: #F5F5F5;}
.main {color: #FFFF00; font-weight: bold; cursor: default; border-color: #B0C4DE; border-style: outset; border-width: 4px; padding: 2px 10px;}
DIV.main:hover {color: #F5F5F5; border-style: inset; border-width: 4px;}
//--></STYLE></HEAD><BODY><DIV ID="setup";>
<DIV ID="menu1"; CLASS="menu"; onMouseOver="display('menu1');" onMouseOut="conceal('menu1');">
<DIV CLASS="main";>M1</DIV>
<DIV ID="menu1poslect";>
<a href="Docs\Doc1.HTML"; target="docView";>S1</a>
<a href="Docs\Doc2.HTML"; target="docView";>S2</a>
<a href="Docs\Doc3.HTML"; target="docView";>S3</a>
<a href="Docs\Doc4.HTML"; target="docView";>S4</a>
<a href="Docs\Doc5.HTML"; target="docView";>S5</a></DIV></DIV>
<DIV ID="menu2"; CLASS="menu"; onMouseOver="display('menu2');" onMouseOut="conceal('menu2');">
<DIV CLASS="main";>M2</DIV>
<DIV ID="menu2poslect";>
<a href="Docs\Doc8.HTML" target="docView";>S1</a>
<a href="Docs\Doc9.HTML" target="docView";>S2</a>
<a href="Docs\Doc10.HTML" target="docView";>S3</a>
<a href="Docs\Doc11.HTML" target="docView";>S4</a>
<a href="Docs\Doc12.HTML" target="docView";>S5</a></DIV></DIV>
<DIV ID="menu3"; CLASS="menu"; onMouseOver="display('menu3');" onMouseOut="conceal('menu3');">
<DIV CLASS="main";>M3</DIV>
<DIV ID="menu3poslect";>
<a href="Docs\Doc14.HTML" target="docView";>S1</a>
<a href="Docs\Doc15.HTML" target="docView";>S2</a>
<a href="Docs\Doc16.HTML" target="docView";>S3</a>
<a href="Docs\Doc15.HTML" target="docView";>S4</a>
<a href="Docs\Doc17.HTML" target="docView";>S5</a></DIV></DIV>
<DIV ID="menu4"; CLASS="menu"; onMouseOver="display('menu4');" onMouseOut="conceal('menu4');">
<DIV CLASS="main";>M4</DIV>
<DIV ID="menu4poslect";>
<a href="Docs\Doc18.HTML" target="docView";>S1</a>
<a href="Docs\Doc19.HTML" target="docView";>S2</a>
<a href="Docs\Doc20.HTML" target="docView";>S3</a>
<a href="Docs\Doc21.HTML" target="docView";>S4</a>
<a href="Docs\Doc15.HTML" target="docView";>S5</a></DIV></DIV>
</DIV><script type="text/JavaScript"<!--
if (DOMCapable) {
conceal('menu1');
conceal('menu2');
conceal('menu3');
conceal('menu4');
}
//--></script></BODY></HTML>
edited: I just fixed the 2nd prob, I had STYLE closing rather then script, did not even catch that one! heh.
Also I noticed another kinky prob, when you attempt to expand the last listing on the menu headers, it opens up near middle section instead and makes it very difficult to get to items within the last section, is there away around this?
It also does work better in IE7b, but still has some probs with it, earlier I was testing on an old old IE version from the early 2000's and it was pretty crummy; I would expect that somewhat though, but in Firefox it should rock out like it is Fight night!
#1 In IE is acts funny swapping from block to none as you move from one button to the next, Firefox it works like a champ.
#2 the second is that is does nto collapse the menus upon loading only after you mouse over them. (Would this need a onload or eventlistener to solve this issue?)
I believe I have everything in order and have failed to see what I am missing, any assistance/advice would be great! thx. I am actually using a total of 9 sections but shortened it down to 4 for ease of viewing.
<HTML><HEAD><BASE target="menu"><script language="JavaScript" type="text/JavaScript"><!--
(document.getElementById ? DOMCapable = true : DOMCapable = false);
function conceal(menuPos) {
if (DOMCapable) {
var setMenu=document.getElementById(menuPos+"poslect");
setMenu.style.display='none';
}
}
function display(menuPos) {
if (DOMCapable) {
var setMenu=document.getElementById(menuPos+"poslect");
setMenu.style.display='block';
}
}
//--></script><STYLE TYPE="text/css"><!--
BODY {background-color: #778899;}
#setup {position: absolute; top: 10px; left: 10px; border-color: #B0C4DE; border-style: inset; border-width: 5px; font-family: Arial; font-size: 12px; text-align: center;}
.menu a {white-space: nowrap; display: block; text-decoration: none; color: #F0FFFF; border-color: #B0C4DE; border-style: outset; border-width: 4px; padding: 2px 10px;}
.menu a:hover {background-color: #B0C4DE; color: #F5F5F5;}
.main {color: #FFFF00; font-weight: bold; cursor: default; border-color: #B0C4DE; border-style: outset; border-width: 4px; padding: 2px 10px;}
DIV.main:hover {color: #F5F5F5; border-style: inset; border-width: 4px;}
//--></STYLE></HEAD><BODY><DIV ID="setup";>
<DIV ID="menu1"; CLASS="menu"; onMouseOver="display('menu1');" onMouseOut="conceal('menu1');">
<DIV CLASS="main";>M1</DIV>
<DIV ID="menu1poslect";>
<a href="Docs\Doc1.HTML"; target="docView";>S1</a>
<a href="Docs\Doc2.HTML"; target="docView";>S2</a>
<a href="Docs\Doc3.HTML"; target="docView";>S3</a>
<a href="Docs\Doc4.HTML"; target="docView";>S4</a>
<a href="Docs\Doc5.HTML"; target="docView";>S5</a></DIV></DIV>
<DIV ID="menu2"; CLASS="menu"; onMouseOver="display('menu2');" onMouseOut="conceal('menu2');">
<DIV CLASS="main";>M2</DIV>
<DIV ID="menu2poslect";>
<a href="Docs\Doc8.HTML" target="docView";>S1</a>
<a href="Docs\Doc9.HTML" target="docView";>S2</a>
<a href="Docs\Doc10.HTML" target="docView";>S3</a>
<a href="Docs\Doc11.HTML" target="docView";>S4</a>
<a href="Docs\Doc12.HTML" target="docView";>S5</a></DIV></DIV>
<DIV ID="menu3"; CLASS="menu"; onMouseOver="display('menu3');" onMouseOut="conceal('menu3');">
<DIV CLASS="main";>M3</DIV>
<DIV ID="menu3poslect";>
<a href="Docs\Doc14.HTML" target="docView";>S1</a>
<a href="Docs\Doc15.HTML" target="docView";>S2</a>
<a href="Docs\Doc16.HTML" target="docView";>S3</a>
<a href="Docs\Doc15.HTML" target="docView";>S4</a>
<a href="Docs\Doc17.HTML" target="docView";>S5</a></DIV></DIV>
<DIV ID="menu4"; CLASS="menu"; onMouseOver="display('menu4');" onMouseOut="conceal('menu4');">
<DIV CLASS="main";>M4</DIV>
<DIV ID="menu4poslect";>
<a href="Docs\Doc18.HTML" target="docView";>S1</a>
<a href="Docs\Doc19.HTML" target="docView";>S2</a>
<a href="Docs\Doc20.HTML" target="docView";>S3</a>
<a href="Docs\Doc21.HTML" target="docView";>S4</a>
<a href="Docs\Doc15.HTML" target="docView";>S5</a></DIV></DIV>
</DIV><script type="text/JavaScript"<!--
if (DOMCapable) {
conceal('menu1');
conceal('menu2');
conceal('menu3');
conceal('menu4');
}
//--></script></BODY></HTML>
edited: I just fixed the 2nd prob, I had STYLE closing rather then script, did not even catch that one! heh.
Also I noticed another kinky prob, when you attempt to expand the last listing on the menu headers, it opens up near middle section instead and makes it very difficult to get to items within the last section, is there away around this?
It also does work better in IE7b, but still has some probs with it, earlier I was testing on an old old IE version from the early 2000's and it was pretty crummy; I would expect that somewhat though, but in Firefox it should rock out like it is Fight night!