xiaodao
07-15-2008, 03:12 AM
Hi,
i used this menu script from dynamic drive and modified slightly, but the problem is weird, it does not show the correct 2nd level menu
detailed code below
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>test</title>
<style>
/* CSS Document */
body{padding:0px; margin:0px; background:url(../images/mainbg.jpg) 0 0 repeat-x #fff; color:#707070; font:14px/18px "Trebuchet MS", Arial, Helvetica, sans-serif;}
div, p, ul, h2, h3, img{padding:0px; margin:0px;}
ul{list-style-type:none;}
/*----TOP PANEL----*/
#topPan{width:747px; height:152px; position:relative; margin:0 auto; padding:0px;}
#topPan img{width:208px; height:58px; position:absolute; top:35px; left:0px;}
#topPan ul{width:480px; height:32px; position:absolute; top:76px; right:0px;}
#topPan ul li{float:left; width:79px; height:32px; padding:0 0 0 1px;}
#topPan ul li a{display:block; width:79px; height:32px; background:url(../images/menubg-normal.gif) 0 0 no-repeat #7E7B00; color:#656565; font-size:11px; font-weight:bold; line-height:32px; text-transform:uppercase; text-align:center; text-decoration:none;}
#topPan ul li a:hover{background:url(../images/menubg-hover.gif) 0 0 no-repeat #7E7B00; color:#7C7900; text-decoration:none;}
#topPan ul li a.current{background:url(../images/menubg-hover.gif) 0 0 no-repeat #7E7B00; color:#7C7900; text-decoration:none;}
#topPan ul.dropdown{width:480px; height:22px; position:absolute; top:119px; right:0px;}
#topPan ul.dropdown li{float:left; width:79px; height:22px; }
#topPan ul.dropdown li a{display:block; width:79px;background:url(../images/vertical-dot.gif) 100% 0 no-repeat #fff; color:#3E3E3E; font-size:11px; text-decoration:none; text-align:center; line-height:22px;}
#topPan ul.dropdown li a:hover{text-decoration:none; background:url(../images/vertical-dot.gif) 100% 0 no-repeat #fff; color:#7C7900;}
#topPan ul.dropdown li.verticallinenone a{display:block; width:79px;background:#fff; color:#3E3E3E; font-size:11px; text-decoration:none; text-align:center; line-height:22px;}
#topPan ul.dropdown li.verticallinenone a:hover{text-decoration:none; background:#fff; color:#7C7900;}
</style>
<script type="text/javascript">
/***********************************************
* DD Tab Menu II script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/
//Set tab to intially be selected when page loads:
//[which tab (1=first tab), ID of tab content to display (or "" if no corresponding tab content)]:
var initialtab=[1, "sc1"];
//Turn menu into single level image tabs (completely hides 2nd level)?
var turntosingle=0; //0 for no (default), 1 for yes
//Disable hyperlinks in 1st level tab images?
var disabletablinks=1; //0 for no (default), 1 for yes
////////Stop editting////////////////
var previoustab="";
if (turntosingle==1){
document.write('<style type="text/css">\n#tabcontentcontainer{display: none;}\n</style>');
}
function expandcontent(cid, aobject){
if (disabletablinks==1){
aobject.onclick=new Function("return false");
}
if (document.getElementById && turntosingle==0){
highlighttab(aobject);
if (previoustab!=""){
document.getElementById(previoustab).style.display="none";
}
if (cid!=""){
document.getElementById(cid).className="dropdown";
previoustab=cid;
}
}
}
function highlighttab(aobject){
if (typeof tabobjlinks=="undefined"){
collectddimagetabs();
}
for (i=0; i<tabobjlinks.length; i++){
tabobjlinks[i].className="";
}
aobject.className="current";
}
function collectddimagetabs(){
var tabobj=document.getElementById("tabs");
tabobjlinks=tabobj.getElementsByTagName("a");
}
function do_onload(){
collectddimagetabs();
expandcontent(initialtab[1], tabobjlinks[initialtab[0]-1]);
}
if (window.addEventListener){
window.addEventListener("load", do_onload, false);
}else if (window.attachEvent){
window.attachEvent("onload", do_onload);
}else if (document.getElementById){
window.onload=do_onload;
}
</script>
</head>
<body>
<div id="topPan">
<a href="index.php"><img src="images/logo.gif" width="208" height="58" border="0" /></a>
<div id="tabs">
<ul>
<li><a href="#" onMouseOver="expandcontent('sc1', this)">Home</a></li>
<li><a href="#" onMouseOver="expandcontent('sc2', this)">Servers</a></li>
<li><a href="#" onMouseOver="expandcontent('sc3', this)">VPS</a></li>
<li><a href="#" onMouseOver="expandcontent('sc4', this)">Hosting</a></li>
<li><a href="#" onMouseOver="expandcontent('sc5', this)">E-commerce</a></li>
<li><a href="#" onMouseOver="expandcontent('sc6', this)">Clients</a></li>
</ul>
</div>
<ul class="dropdown" id="sc1">
<li><a href="#">About Us</a></li>
<li><a href="#">Policy</a></li>
<li><a href="#">testimonial</a></li>
</ul>
<ul class="dropdown" id="sc2">
<li><a href="#">orange</a></li>
<li><a href="#">apple</a></li>
<li><a href="#">waterlemon</a></li>
</ul>
<ul class="dropdown" id="sc3">
<li><a href="#">orange</a></li>
<li><a href="#">waterlemon</a></li>
</ul>
<ul class="dropdown" id="sc4">
<li><a href="#>Web</a></li>
<li><a href="#">Email</a></li>
</ul>
<ul class="dropdown" id="sc5">
<li><a href="#">Licenses</a></li>
<li><a href="#">Web Designs</a></li>
</ul>
<ul class="dropdown" id="sc6">
<li><a href="login.php">Login</a></li>
<li><a href="register.php">Register</a></li>
</ul>
</div>
</body>
</html>
I have set
var initialtab=[1, "sc1"];
but apparently the script does not show "sc1" but i mixture of the other submenus. please help.
i used this menu script from dynamic drive and modified slightly, but the problem is weird, it does not show the correct 2nd level menu
detailed code below
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>test</title>
<style>
/* CSS Document */
body{padding:0px; margin:0px; background:url(../images/mainbg.jpg) 0 0 repeat-x #fff; color:#707070; font:14px/18px "Trebuchet MS", Arial, Helvetica, sans-serif;}
div, p, ul, h2, h3, img{padding:0px; margin:0px;}
ul{list-style-type:none;}
/*----TOP PANEL----*/
#topPan{width:747px; height:152px; position:relative; margin:0 auto; padding:0px;}
#topPan img{width:208px; height:58px; position:absolute; top:35px; left:0px;}
#topPan ul{width:480px; height:32px; position:absolute; top:76px; right:0px;}
#topPan ul li{float:left; width:79px; height:32px; padding:0 0 0 1px;}
#topPan ul li a{display:block; width:79px; height:32px; background:url(../images/menubg-normal.gif) 0 0 no-repeat #7E7B00; color:#656565; font-size:11px; font-weight:bold; line-height:32px; text-transform:uppercase; text-align:center; text-decoration:none;}
#topPan ul li a:hover{background:url(../images/menubg-hover.gif) 0 0 no-repeat #7E7B00; color:#7C7900; text-decoration:none;}
#topPan ul li a.current{background:url(../images/menubg-hover.gif) 0 0 no-repeat #7E7B00; color:#7C7900; text-decoration:none;}
#topPan ul.dropdown{width:480px; height:22px; position:absolute; top:119px; right:0px;}
#topPan ul.dropdown li{float:left; width:79px; height:22px; }
#topPan ul.dropdown li a{display:block; width:79px;background:url(../images/vertical-dot.gif) 100% 0 no-repeat #fff; color:#3E3E3E; font-size:11px; text-decoration:none; text-align:center; line-height:22px;}
#topPan ul.dropdown li a:hover{text-decoration:none; background:url(../images/vertical-dot.gif) 100% 0 no-repeat #fff; color:#7C7900;}
#topPan ul.dropdown li.verticallinenone a{display:block; width:79px;background:#fff; color:#3E3E3E; font-size:11px; text-decoration:none; text-align:center; line-height:22px;}
#topPan ul.dropdown li.verticallinenone a:hover{text-decoration:none; background:#fff; color:#7C7900;}
</style>
<script type="text/javascript">
/***********************************************
* DD Tab Menu II script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/
//Set tab to intially be selected when page loads:
//[which tab (1=first tab), ID of tab content to display (or "" if no corresponding tab content)]:
var initialtab=[1, "sc1"];
//Turn menu into single level image tabs (completely hides 2nd level)?
var turntosingle=0; //0 for no (default), 1 for yes
//Disable hyperlinks in 1st level tab images?
var disabletablinks=1; //0 for no (default), 1 for yes
////////Stop editting////////////////
var previoustab="";
if (turntosingle==1){
document.write('<style type="text/css">\n#tabcontentcontainer{display: none;}\n</style>');
}
function expandcontent(cid, aobject){
if (disabletablinks==1){
aobject.onclick=new Function("return false");
}
if (document.getElementById && turntosingle==0){
highlighttab(aobject);
if (previoustab!=""){
document.getElementById(previoustab).style.display="none";
}
if (cid!=""){
document.getElementById(cid).className="dropdown";
previoustab=cid;
}
}
}
function highlighttab(aobject){
if (typeof tabobjlinks=="undefined"){
collectddimagetabs();
}
for (i=0; i<tabobjlinks.length; i++){
tabobjlinks[i].className="";
}
aobject.className="current";
}
function collectddimagetabs(){
var tabobj=document.getElementById("tabs");
tabobjlinks=tabobj.getElementsByTagName("a");
}
function do_onload(){
collectddimagetabs();
expandcontent(initialtab[1], tabobjlinks[initialtab[0]-1]);
}
if (window.addEventListener){
window.addEventListener("load", do_onload, false);
}else if (window.attachEvent){
window.attachEvent("onload", do_onload);
}else if (document.getElementById){
window.onload=do_onload;
}
</script>
</head>
<body>
<div id="topPan">
<a href="index.php"><img src="images/logo.gif" width="208" height="58" border="0" /></a>
<div id="tabs">
<ul>
<li><a href="#" onMouseOver="expandcontent('sc1', this)">Home</a></li>
<li><a href="#" onMouseOver="expandcontent('sc2', this)">Servers</a></li>
<li><a href="#" onMouseOver="expandcontent('sc3', this)">VPS</a></li>
<li><a href="#" onMouseOver="expandcontent('sc4', this)">Hosting</a></li>
<li><a href="#" onMouseOver="expandcontent('sc5', this)">E-commerce</a></li>
<li><a href="#" onMouseOver="expandcontent('sc6', this)">Clients</a></li>
</ul>
</div>
<ul class="dropdown" id="sc1">
<li><a href="#">About Us</a></li>
<li><a href="#">Policy</a></li>
<li><a href="#">testimonial</a></li>
</ul>
<ul class="dropdown" id="sc2">
<li><a href="#">orange</a></li>
<li><a href="#">apple</a></li>
<li><a href="#">waterlemon</a></li>
</ul>
<ul class="dropdown" id="sc3">
<li><a href="#">orange</a></li>
<li><a href="#">waterlemon</a></li>
</ul>
<ul class="dropdown" id="sc4">
<li><a href="#>Web</a></li>
<li><a href="#">Email</a></li>
</ul>
<ul class="dropdown" id="sc5">
<li><a href="#">Licenses</a></li>
<li><a href="#">Web Designs</a></li>
</ul>
<ul class="dropdown" id="sc6">
<li><a href="login.php">Login</a></li>
<li><a href="register.php">Register</a></li>
</ul>
</div>
</body>
</html>
I have set
var initialtab=[1, "sc1"];
but apparently the script does not show "sc1" but i mixture of the other submenus. please help.