我在MasterPage中做了一个竖向的可收缩的导航栏,在IE6下可以正常的收缩,但是在IE7下则无法实现收缩,不知道原因何在,急求解决办法!!
附代码如下:
<body>
<ul id="nav">
<li><a href="Welcome.aspx">返回首页</a></li>
<li><a href="#" onmousedown="showSubMenu('SubMenu1');">单位管理</a>
<ul id="SubMenu1">
<li><a href="Main.aspx" >本单位信息</a></li>
<li><a href="SubOrganInfo.aspx" >下级单位信息</a></li>
<li><a href="CreateOrgan.aspx" >创建单位</a></li>
</ul>
</li>
<li><a href="#" onmousedown="showSubMenu('SubMenu2');">人员管理</a>
<ul id="SubMenu2">
<li><a href="AdminInfo.aspx" >本人信息</a></li>
<li><a href="PersonInfo.aspx" >人员信息管理</a></li>
<li><a href="CreatePerson.aspx" >添加人员</a></li>
</ul>
</li> </ul><script type="text/javascript">
var lastSubMenuID;
//记录最后点击的子菜单
function doRecord(subMenuID)
{
document.getElementById(subMenuID).style.display = "block";
lastSubMenuID = subMenuID;
return lastSubMenuID;
}
//隐藏子菜单
function hideLastSubMenu()
{
if(lastSubMenuID == undefined || lastSubMenuID == "")
{
return;
}
else
{
var lastSubMenu = document.getElementById(lastSubMenuID);
lastSubMenu.style.display = "none";
}
}
//显示子菜单
function showSubMenu(subMenuID)
{
if(lastSubMenuID == subMenuID)
{
if(document.getElementById(lastSubMenuID).style.display == "block")
{
document.getElementById(lastSubMenuID).style.display = "none";
return;
}
}
if(lastSubMenuID == undefined)
{
doRecord(subMenuID);
}
else
{
hideLastSubMenu();
doRecord(subMenuID);
}
changeMenuState(subMenuID);
}
//改变子菜单的样式
function changeMenuState(subMenuID)
{
var subMenu = document.getElementById(subMenuID);
subMenu.style.display = "block";
}
</script></body>
附代码如下:
<body>
<ul id="nav">
<li><a href="Welcome.aspx">返回首页</a></li>
<li><a href="#" onmousedown="showSubMenu('SubMenu1');">单位管理</a>
<ul id="SubMenu1">
<li><a href="Main.aspx" >本单位信息</a></li>
<li><a href="SubOrganInfo.aspx" >下级单位信息</a></li>
<li><a href="CreateOrgan.aspx" >创建单位</a></li>
</ul>
</li>
<li><a href="#" onmousedown="showSubMenu('SubMenu2');">人员管理</a>
<ul id="SubMenu2">
<li><a href="AdminInfo.aspx" >本人信息</a></li>
<li><a href="PersonInfo.aspx" >人员信息管理</a></li>
<li><a href="CreatePerson.aspx" >添加人员</a></li>
</ul>
</li> </ul><script type="text/javascript">
var lastSubMenuID;
//记录最后点击的子菜单
function doRecord(subMenuID)
{
document.getElementById(subMenuID).style.display = "block";
lastSubMenuID = subMenuID;
return lastSubMenuID;
}
//隐藏子菜单
function hideLastSubMenu()
{
if(lastSubMenuID == undefined || lastSubMenuID == "")
{
return;
}
else
{
var lastSubMenu = document.getElementById(lastSubMenuID);
lastSubMenu.style.display = "none";
}
}
//显示子菜单
function showSubMenu(subMenuID)
{
if(lastSubMenuID == subMenuID)
{
if(document.getElementById(lastSubMenuID).style.display == "block")
{
document.getElementById(lastSubMenuID).style.display = "none";
return;
}
}
if(lastSubMenuID == undefined)
{
doRecord(subMenuID);
}
else
{
hideLastSubMenu();
doRecord(subMenuID);
}
changeMenuState(subMenuID);
}
//改变子菜单的样式
function changeMenuState(subMenuID)
{
var subMenu = document.getElementById(subMenuID);
subMenu.style.display = "block";
}
</script></body>
解决方案 »
- 我想用js和HTML实现新浪微博的收藏、评论等功能,请高手指点一下,给个例子,谢谢啦
- Easyui Grid修改记录排序的问题 能实现效果 但还是有报错 请高手帮忙检查一下
- 求教这个如何封装?在线等,谢了
- 用javascrip如何t判断多选柜是否被选中
- 问个比较基础的问题
- 怎样才能取消Scripting.FileSystemObject弹出来的提示呢?
- char a='\0';
- 技术问题:如何实现用js完成与flash的上下移动的效果
- 急急急,</font><font id="singInFont" color="#FF0000" onClick="changeAttribute(<%=charCLHJ%>)" style="cursor:hand" >怎么清除属性
- 如何删除数组中重复的值?
- Ext.getDom('uploadFile0').outerHTML 为什么返回的是undefind
- 【跪求】Flex的开发工具及其安装过程,急急急!!
<ul id="SubMenu1" style="display:block">
<ul id="SubMenu2" style="display:block">
<ul id="SubMenu1" style="display:block">
<ul id="SubMenu2" style="display:block">
<!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=gb2312" />
<title>无标题文档</title>
<script type="text/javascript">
var lastSubMenuID=false;
//记录最后点击的子菜单
function doRecord(subMenuID)
{
document.getElementById(subMenuID).style.display = "block";
lastSubMenuID = subMenuID;
return lastSubMenuID;
}
//隐藏子菜单
function hideLastSubMenu()
{
if(lastSubMenuID ==false || lastSubMenuID == "")
{
return;
}
else
{
var lastSubMenu = document.getElementById(lastSubMenuID);
lastSubMenu.style.display = "none";
}
}
//显示子菜单
function showSubMenu(subMenuID)
{
if(lastSubMenuID == subMenuID)
{
if(document.getElementById(lastSubMenuID).style.display == "block")
{
document.getElementById(lastSubMenuID).style.display = "none";
return;
}
}
if(lastSubMenuID == false)
{
doRecord(subMenuID);
}
else
{
hideLastSubMenu();
doRecord(subMenuID);
}
changeMenuState(subMenuID);
}
//改变子菜单的样式
function changeMenuState(subMenuID)
{
var subMenu = document.getElementById(subMenuID);
subMenu.style.display = "block";
} </script>
<style>
#nav{
}
#nav li{
float:left;
width:100px;
margin:0px;
padding:0px;
list-style:none;
}
</style>
</head><body>
<ul id="nav">
<li> <a href="Welcome.aspx">返回首页 </a> </li>
<li> <a href="#" onmousedown="showSubMenu('SubMenu1');">单位管理 </a>
<ul id="SubMenu1" style="display:none;">
<li> <a href="Main.aspx" >本单位信息 </a> </li>
<li> <a href="SubOrganInfo.aspx" >下级单位信息 </a> </li>
<li> <a href="CreateOrgan.aspx" >创建单位 </a> </li>
</ul>
</li>
<li> <a href="#" onmousedown="showSubMenu('SubMenu2');">人员管理 </a>
<ul id="SubMenu2" style="display:none;">
<li> <a href="AdminInfo.aspx" >本人信息 </a> </li>
<li> <a href="PersonInfo.aspx" >人员信息管理 </a> </li>
<li> <a href="CreatePerson.aspx" >添加人员 </a> </li>
</ul>
</li> </ul>
</body>
</html>
加下,改了改
没发现问题
跟undefined false "" 等比较的话, 最好用if(!lastSubMenuID)这样比较好.唉. 什么时候要是有人能点名向我提问就high了.
<!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 runat="server">
<title>无标题文档</title>
<style type="text/css">
body {
background-color: White;
margin:0;
/*background-image: url(pics/beijing.png);*/
}
.frame {
width : 99.9% ;
border : 0px 0px;
}
#left{
background:#eeeeee;
}
#left ul{
margin:0;
padding:0;
}
#nav {
margin:0;
margin-left:3px;
margin-top:10px;
padding;0;
}
#nav li{
margin:0;
padding:0;
list-style-type:none;
text-align:center;
height :30px;
width:150px;
background-image:url(pics/navi.gif);
border-bottom:#FFFFFF 5px solid;
}
#nav ul{
margin:0;
padding:0;
display:none;
}
li a
{
font-weight:bold;
font-size:10pt;
width:150px;
color:#000000;
line-height:20pt;
text-decoration:none;
}
#nav li a:hover{
color:#cc9933;
font-weight:bold;
}
#nav li ul{
margin-top:0px;
margin:0;
padding:0;
list-style-type:none;
background-color:#f0ffff;
}
#nav li ul li{
width:150px;
margin:0;
margin-top:3px;
padding:0;
font-weight:normal;
background-image:none;
background-color:#f0ffff;
border-bottom:#E2EDF8 3px solid;
}
#nav li ul li a{
font-weight:normal;
color:#000000;
}
#header {
height : 120px;
width:1024px;
background-image : url(pics/Logo.gif) ;
<%--border:#333333 1px solid;--%>
}
.link{
margin:0;
padding:0;
}
#content {
position: relaitive;
margin:0 auto;
text-align:left;
border-bottom-style:double;
height:570px;
<%--border:#333333 1px solid;--%>
}
#footer {
font-size:14px;
text-align: center;
height:15px;
display:block;
<%--border:#333333 1px solid;--%>
}
#state a{
text-decoration:none;
color:#000000;
}
#state a:hover{
color:#cc9933;
font-weight:bold;
text-decoration:underline;
}
.STYLE1 {color: #FF0000}
</style>
</head>
<ul id="nav">
<li><a href="Welcome.aspx">返回首页</a></li>
<li><a href="#"onmousedown="tt(this);">单位管理</a>
<ul id="SubMenu1">
<li><a href="Main.aspx">本单位信息</a></li>
<li><a href="SubOrganInfo.aspx">下级单位信息</a></li>
<li><a href="CreateOrgan.aspx">创建单位</a></li>
</ul>
</li>
<li><a href="#"onmousedown="tt(this);">人员管理</a>
<ul id="SubMenu2">
<li><a href="AdminInfo.aspx">本人信息</a></li>
<li><a href="PersonInfo.aspx">人员信息管理</a></li>
<li><a href="CreatePerson.aspx">添加人员</a></li>
</ul>
</li></ul><script language="javascript">
function tt(obj){
var obj1=obj.parentNode;
var objs=obj1.parentNode.childNodes;
for(var i=0;i<objs.length;i++){
var obj2=objs[i].childNodes[2];
if(obj2&&obj2.nodeName=="UL"){
if(objs[i]==obj1){
if(obj2.style.display=="none"||obj2.style.display==""){
obj2.style.display="block";
}
else{
obj2.style.display="none";
}
}
else{
obj2.style.display="none";
}
}
}
}
</script>
</body>
<ul id="nav">
<li><a href="Welcome.aspx">返回首页</a></li>
<li><a href="#"onmousedown="tt(this);">单位管理</a>
<ul id="SubMenu1">
<li><a href="Main.aspx">本单位信息</a></li>
<li><a href="SubOrganInfo.aspx">下级单位信息</a></li>
<li><a href="CreateOrgan.aspx">创建单位</a></li>
</ul>
</li>
<li><a href="#"onmousedown="tt(this);">人员管理</a>
<ul id="SubMenu2">
<li><a href="AdminInfo.aspx">本人信息</a></li>
<li><a href="PersonInfo.aspx">人员信息管理</a></li>
<li><a href="CreatePerson.aspx">添加人员</a></li>
</ul>
</li></ul><script language="javascript">
function tt(obj){
var obj1=obj.parentNode;
var objs=obj1.parentNode.childNodes;
for(var i=0;i<objs.length;i++){
var obj2=objs[i].childNodes[2];
if(obj2&&obj2.nodeName=="UL"){
if(objs[i]==obj1){
if(obj2.style.display=="none"||obj2.style.display==""){
obj2.style.display="block";
}
else{
obj2.style.display="none";
}
}
else{
obj2.style.display="none";
}
}
}
}
</script>
</body>
height : 120px;
width:1024px;
background-image : url(pics/Logo.gif) ;
<%--border:#333333 1px solid;--%>
}
最下面一行是何用意!!?
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题文档 </title>
<style type="text/css">
body {
background-color: White;
margin:0;
/*background-image: url(pics/beijing.png);*/
}
.frame {
width : 99.9% ;
border : 0px 0px;
}
#left{
background:#eeeeee;
}
#left ul{
margin:0;
padding:0;
}
#nav {
margin:0;
margin-left:3px;
margin-top:10px;
padding;0;
}
#nav li{
margin:0;
padding:0;
list-style-type:none;
text-align:center;
height :30px;
width:150px;
background-image:url(pics/navi.gif);
border-bottom:#FFFFFF 5px solid;
}
#nav ul{
margin:0;
padding:0;
display:none;
}
li a
{
font-weight:bold;
font-size:10pt;
width:150px;
color:#000000;
line-height:20pt;
text-decoration:none;
}
#nav li a:hover{
color:#cc9933;
font-weight:bold;
}
#nav li ul{
margin-top:0px;
margin:0;
padding:0;
list-style-type:none;
background-color:#f0ffff;
}
#nav li ul li{
width:150px;
margin:0;
margin-top:3px;
padding:0;
font-weight:normal;
background-image:none;
background-color:#f0ffff;
border-bottom:#E2EDF8 3px solid;
}
#nav li ul li a{
font-weight:normal;
color:#000000;
}
#header {
height : 120px;
width:1024px;
background-image : url(pics/Logo.gif) ;
<%--border:#333333 1px solid;--%>
}
.link{
margin:0;
padding:0;
}
#content {
position: relaitive;
margin:0 auto;
text-align:left;
border-bottom-style:double;
height:570px;
<%--border:#333333 1px solid;--%>
}
#footer {
font-size:14px;
text-align: center;
height:15px;
display:block;
<%--border:#333333 1px solid;--%>
}
#state a{
text-decoration:none;
color:#000000;
}
#state a:hover{
color:#cc9933;
font-weight:bold;
text-decoration:underline;
}
.STYLE1 {color: #FF0000}
</style>
</head>
<body>
<ul id="nav">
<li> <a href="Welcome.aspx">返回首页 </a> </li>
<li> <a href="#" onmousedown="showSubMenu('SubMenu1');">单位管理 </a>
<ul id="SubMenu1">
<li> <a href="Main.aspx" >本单位信息 </a> </li>
<li> <a href="SubOrganInfo.aspx" >下级单位信息 </a> </li>
<li> <a href="CreateOrgan.aspx" >创建单位 </a> </li>
</ul>
</li>
<li> <a href="#" onmousedown="showSubMenu('SubMenu2');">人员管理 </a>
<ul id="SubMenu2">
<li> <a href="AdminInfo.aspx" >本人信息 </a> </li>
<li> <a href="PersonInfo.aspx" >人员信息管理 </a> </li>
<li> <a href="CreatePerson.aspx" >添加人员 </a> </li>
</ul>
</li>
</ul>
<script type="text/javascript">
var lastSubMenuID;
//记录最后点击的子菜单
function doRecord(subMenuID)
{
document.getElementById(subMenuID).style.display = "block";
lastSubMenuID = subMenuID;
return lastSubMenuID;
}
//隐藏子菜单
function hideLastSubMenu()
{
if(lastSubMenuID == undefined || lastSubMenuID == "")
{
return;
}
else
{
var lastSubMenu = document.getElementById(lastSubMenuID);
lastSubMenu.style.display = "none";
}
}
//显示子菜单
function showSubMenu(subMenuID)
{
if(lastSubMenuID == subMenuID)
{
if(document.getElementById(lastSubMenuID).style.display == "block")
{
document.getElementById(lastSubMenuID).style.display = "none";
return;
}
}
if(lastSubMenuID == undefined)
{
doRecord(subMenuID);
}
else
{
hideLastSubMenu();
doRecord(subMenuID);
}
changeMenuState(subMenuID);
}
//改变子菜单的样式
function changeMenuState(subMenuID)
{
var subMenu = document.getElementById(subMenuID);
subMenu.style.display = "block";
}
</script>
</body>
<!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 runat="server">
<title>无标题文档 </title>
<style type="text/css">
body {
background-color: White;
margin:0;
/*background-image: url(pics/beijing.png);*/
}
.frame {
width : 99.9% ;
border : 0px 0px;
}
#left{
background:#eeeeee;
}
#left ul{
margin:0;
padding:0;
}
#nav {
margin:0;
margin-left:3px;
margin-top:10px;
padding;0;
}
#nav li{
margin:0;
padding:0;
list-style-type:none;
text-align:center;
height :30px;
width:150px;
background-image:url(pics/navi.gif);
border-bottom:#FFFFFF 5px solid;
}
#nav ul{
margin:0;
padding:0;
display:none;
}
li a
{
font-weight:bold;
font-size:10pt;
width:150px;
color:#000000;
line-height:20pt;
text-decoration:none;
}
#nav li a:hover{
color:#cc9933;
font-weight:bold;
}
#nav li ul{
margin-top:0px;
margin:0;
padding:0;
list-style-type:none;
background-color:#f0ffff;
}
#nav li ul li{
width:150px;
margin:0;
margin-top:3px;
padding:0;
font-weight:normal;
background-image:none;
background-color:#f0ffff;
border-bottom:#E2EDF8 3px solid;
}
#nav li ul li a{
font-weight:normal;
color:#000000;
}
#header {
height : 120px;
width:1024px;
background-image : url(pics/Logo.gif) ;
<%--border:#333333 1px solid;--%>
}
.link{
margin:0;
padding:0;
}
#content {
position: relaitive;
margin:0 auto;
text-align:left;
border-bottom-style:double;
height:570px;
<%--border:#333333 1px solid;--%>
}
#footer {
font-size:14px;
text-align: center;
height:15px;
display:block;
<%--border:#333333 1px solid;--%>
}
#state a{
text-decoration:none;
color:#000000;
}
#state a:hover{
color:#cc9933;
font-weight:bold;
text-decoration:underline;
}
.STYLE1 {color: #FF0000}
</style>
</head>
<body>
<ul id="nav">
<li> <a href="Welcome.aspx">返回首页 </a> </li>
<li> <a href="#" onmousedown="showSubMenu('SubMenu1');">单位管理 </a>
<ul id="SubMenu1">
<li> <a href="Main.aspx" >本单位信息 </a> </li>
<li> <a href="SubOrganInfo.aspx" >下级单位信息 </a> </li>
<li> <a href="CreateOrgan.aspx" >创建单位 </a> </li>
</ul>
</li>
<li> <a href="#" onmousedown="showSubMenu('SubMenu2');">人员管理 </a>
<ul id="SubMenu2">
<li> <a href="AdminInfo.aspx" >本人信息 </a> </li>
<li> <a href="PersonInfo.aspx" >人员信息管理 </a> </li>
<li> <a href="CreatePerson.aspx" >添加人员 </a> </li>
</ul>
</li>
</ul>
<script type="text/javascript">
var lastSubMenuID;
//记录最后点击的子菜单
function doRecord(subMenuID)
{
document.getElementById(subMenuID).style.display = "block";
lastSubMenuID = subMenuID;
return lastSubMenuID;
}
//隐藏子菜单
function hideLastSubMenu()
{
if(lastSubMenuID == undefined || lastSubMenuID == "")
{
return;
}
else
{
var lastSubMenu = document.getElementById(lastSubMenuID);
lastSubMenu.style.display = "none";
}
}
//显示子菜单
function showSubMenu(subMenuID)
{
if(lastSubMenuID == subMenuID)
{
if(document.getElementById(lastSubMenuID).style.display == "block")
{
document.getElementById(lastSubMenuID).style.display = "none";
return;
}
}
if(lastSubMenuID == undefined)
{
doRecord(subMenuID);
}
else
{
hideLastSubMenu();
doRecord(subMenuID);
}
changeMenuState(subMenuID);
}
//改变子菜单的样式
function changeMenuState(subMenuID)
{
var subMenu = document.getElementById(subMenuID);
subMenu.style.display = "block";
}
</script>
</body>