有了问题很奇怪,急,在线等,

zhanglongjason 2010-09-21 09:45:49
是这样的,我这个代码是一个点击后,弹出层的下拉框效果,可是有个问题很奇怪,就是刷新后点击按钮弹出层要点两下才能出来下拉框,点击后了,在点就正常了,问题是只要刷新开始就要点两下才正常,请大侠们帮忙看看哪里出错了,谢谢了,


<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>无标题页</title>
</head>
<body><%--BORDER-RIGHT:red 2px solid; PADDING-RIGHT:15px; BORDER-TOP:red 2px solid; DISPLAY: none; PADDING-LEFT:15px; BACKGROUND: yellow; PADDING-BOTTOM:15px; BORDER-LEFT:red 2px solid; WIDTH: 140px; PADDING-TOP: 15px; BORDER-BOTTOM:red 2px solid; TOP: 30px--%>
<form id="form1" runat="server">
<div>
<style type="text/css">.menubar {
BORDER-RIGHT: 1px outset; BORDER-TOP: 1px outset; BACKGROUND: #0099cc; BORDER-LEFT: 1px outset; WIDTH: 100px; CURSOR: default; COLOR: yellow; BORDER-BOTTOM: 1px outset; POSITION: absolute; TOP: 10px; HEIGHT: 20px
}
.menu { border-right: red 2px solid;
border-top: red 2px solid;
border-bottom: red 2px solid;
border-left: red 2px solid;
display: none;
background: yellow;
padding-bottom: 15px;
padding-top: 15px;

}
.menu A {
COLOR: blue; TEXT-DECORATION: none
}
.menu A:hover {
COLOR: #ffffff
}
</style>
<script language="javascript">
function menuControl(show)
{
window.event.cancelBubble=true;
var objID=event.srcElement.id;
var index=objID.indexOf("_");
var mainID=objID.substring(0,index);
var numID=objID.substring(index+1,objID.length);

if(mainID=="menubar")
{
var obj=eval("menu_"+numID);
if(obj.style.display=="none")
eval("showMenu("+"menu_"+numID+")");
else
eval("hideMenu("+"menu_"+numID+")");
}
}
var nbottom=0,speed=7;
function displayMenu(obj)
{
obj.style.clip="rect(0 100% "+nbottom+"% 0)";
nbottom+=speed;
if(nbottom<=100)
{
timerID=setTimeout("displayMenu("+obj.id+"),70");
}
else clearTimeout(timerID);
}
function showMenu(obj)
{
obj.style.display="block";
obj.style.clip="rect(0 0 0 0)";
nbottom=5;
displayMenu(obj);
}
function hideMenu(obj)
{
nbottom=0;
obj.style.display="none";
}
function keepMenu(obj)
{
obj.style.display="block";
}
</script>
<table style="FONT-SIZE: 15px" cellSpacing="0" cellPadding="0" width="400" border="0">
<tbody>
<TR>
<TD width="20%">
<DIV class="menubar" id="menubar_1" onclick="menuControl(1)"
align="center" style="background-image:url('bg_btn.JPG')">教育网站 </DIV></TD>
<TD width="20%">
<DIV class="menubar" id="menubar_2" onclick="menuControl(1)"
align="center">电脑网站 </DIV></TD>
<TD width="20%">
<DIV class="menubar" id="menubar_3" onclick="menuControl(1)"
align="center">免费邮件 </DIV></TD>
<TD width="20%">
<DIV class="menubar" id="menubar_4" onclick="menuControl(1)"
align="center">其它网站 </DIV></TD></TR>
<TR>
<TD width="20%">

<DIV class="menu" id="menu_1" onclick="keepMenu(this)" align="left">
<div style="float:left; margin-left:-55px;height:50px;">
<ul style="list-style-type:none; line-height:180%; float:left">
<li style="width:107px;" onmouseover="this.style.backgroundColor='#0080C0'" onmouseout="this.style.backgroundColor=''"><font style="float:left; margin-left:20px; font-size:12px;">最新</font></li>
<li style="width:107px;" onmouseover="this.style.backgroundColor='#0080C0'" onmouseout="this.style.backgroundColor=''"><font style="float:left; margin-left:20px;font-size:12px;">Target map</font></li>
<li style="width:107px;" onmouseover="this.style.backgroundColor='#0080C0'" onmouseout="this.style.backgroundColor=''"><font style="float:left; margin-left:20px;font-size:12px;">筛选</font></li>
<li style="width:107px;" onmouseover="this.style.backgroundColor='#0080C0'" onmouseout="this.style.backgroundColor=''"><font style="float:left; margin-left:20px;font-size:12px;">推荐</font></li>
<li style="width:107px;" onmouseover="this.style.backgroundColor='#0080C0'" onmouseout="this.style.backgroundColor=''"><font style="float:left; margin-left:20px;font-size:12px;">面试</font></li>
<li style="width:107px;" onmouseover="this.style.backgroundColor='#0080C0'" onmouseout="this.style.backgroundColor=''"><font style="float:left; margin-left:20px;font-size:12px;">offer</font></li>
<li style="width:107px;" onmouseover="this.style.backgroundColor='#0080C0'" onmouseout="this.style.backgroundColor=''"><font style="float:left; margin-left:20px;font-size:12px;">录用</font></li>
</ul></div>
</DIV></TD>
<TD width="20%">
<DIV class="menu" id="menu_2" onclick="keepMenu(this)"
align="left"><A
href="http://www.yesky.com/">天极网</A><BR><A
href="http://www.cfan.cn.net/">电脑爱好者</A><BR><A
href="http://www.intoweb.com.cn/">上网杂志</A> </DIV></TD>
<TD width="20%">
<DIV class="menu" id="menu_3" onclick="keepMenu(this)"
align="left"><A
href="http://www.163.com/">163电子邮件</A><BR><A
href="http://freemail.263.net/">首都在线</A><BR><A
href="http://www.21cn.com/">21CN电子邮件</A><BR><A
href="http://www.chinese.com/">炎皇在线</A> </DIV></TD>
<TD width="20%">
<DIV class="menu" id="menu_4" onclick="keepMenu(this)"
align="left"><A
href="http://www.sohu.com.cn/">搜狐</A><BR><A
href="http://www.yahoo.com/">雅虎</A><BR><A
href="http://www.cseek.com/">搜索客</A><BR><A
href="http://www.sina.com/">新浪网</A><BR><A
href="http://202.102.4.31/51windows/js/httP;//www.cqcas.edu.cn/user/sailing">远航网站</A>
</DIV></TD></TR></tbody></table>
</div>
</form>
</body>
</html>
...全文
89 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhanglongjason 2010-09-21
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 fellowcheng 的回复:]

JScript code
if (obj.style.display == "none")
showMenu(obj);
else
hideMenu(obj);


你的判断逻辑就是当隐藏的时候才显示,所以初始状态要设置为style="display:none;"
[/Quote]对的
fellowcheng 2010-09-21
  • 打赏
  • 举报
回复
if (obj.style.display == "none")
showMenu(obj);
else
hideMenu(obj);

你的判断逻辑就是当隐藏的时候才显示,所以初始状态要设置为style="display:none;"
fellowcheng 2010-09-21
  • 打赏
  • 举报
回复
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>无标题页</title>
<style type="text/css">
.menubar
{
border-right: 1px outset;
border-top: 1px outset;
background: #0099cc;
border-left: 1px outset;
width: 100px;
cursor: default;
color: yellow;
border-bottom: 1px outset;
position: absolute;
top: 10px;
height: 20px;
}
.menu
{
border-right: red 2px solid;
border-top: red 2px solid;
border-bottom: red 2px solid;
border-left: red 2px solid;
display: none;
background: yellow;
padding-bottom: 15px;
padding-top: 15px;
}
.menu A
{
color: blue;
text-decoration: none;
}
.menu A:hover
{
color: #ffffff;
}
</style>

<script language="javascript">
function menuControl(show) {
window.event.cancelBubble = true;
var objID = event.srcElement.id;
var index = objID.indexOf("_");
var mainID = objID.substring(0, index);
var numID = objID.substring(index + 1, objID.length);

if (mainID == "menubar") {
var obj = eval("menu_" + numID);
if (obj.style.display == "none")
showMenu(obj);
else
hideMenu(obj);
}
}
var nbottom = 0, speed = 7;
function displayMenu(obj) {
obj.style.clip = "rect(0 100% " + nbottom + "% 0)";
nbottom += speed;
if (nbottom <= 100) {
timerID = setTimeout("displayMenu(" + obj.id + "),70");
}
else clearTimeout(timerID);
}
function showMenu(obj) {
obj.style.display = "block";
obj.style.clip = "rect(0 0 0 0)";
nbottom = 5;
displayMenu(obj);
}
function hideMenu(obj) {
nbottom = 0;
obj.style.display = "none";
}
function keepMenu(obj) {
obj.style.display = "block";
}
</script>

</head>
<body>
<%--BORDER-RIGHT:red 2px solid; PADDING-RIGHT:15px; BORDER-TOP:red 2px solid; DISPLAY: none; PADDING-LEFT:15px; BACKGROUND: yellow; PADDING-BOTTOM:15px; BORDER-LEFT:red 2px solid; WIDTH: 140px; PADDING-TOP: 15px; BORDER-BOTTOM:red 2px solid; TOP: 30px--%>
<form id="form1" runat="server">
<div>
<table style="font-size: 15px" cellspacing="0" cellpadding="0" width="400" border="0">
<tbody>
<tr>
<td width="20%">
<div class="menubar" id="menubar_1" onclick="menuControl(1)" align="center" style="background-image: url('bg_btn.JPG')">
教育网站
</div>
</td>
<td width="20%">
<div class="menubar" id="menubar_2" onclick="menuControl(1)" align="center">
电脑网站
</div>
</td>
<td width="20%">
<div class="menubar" id="menubar_3" onclick="menuControl(1)" align="center">
免费邮件
</div>
</td>
<td width="20%">
<div class="menubar" id="menubar_4" onclick="menuControl(1)" align="center">
其它网站
</div>
</td>
</tr>
<tr>
<td width="20%">
<div class="menu" id="menu_1" onclick="keepMenu(this)" align="left" style="display:none;">
<div style="float: left; margin-left: -55px; height: 50px;">
<ul style="list-style-type: none; line-height: 180%; float: left">
<li style="width: 107px;" onmouseover="this.style.backgroundColor='#0080C0'" onmouseout="this.style.backgroundColor=''">
<font style="float: left; margin-left: 20px; font-size: 12px;">最新</font></li>
<li style="width: 107px;" onmouseover="this.style.backgroundColor='#0080C0'" onmouseout="this.style.backgroundColor=''">
<font style="float: left; margin-left: 20px; font-size: 12px;">Target map</font></li>
<li style="width: 107px;" onmouseover="this.style.backgroundColor='#0080C0'" onmouseout="this.style.backgroundColor=''">
<font style="float: left; margin-left: 20px; font-size: 12px;">筛选</font></li>
<li style="width: 107px;" onmouseover="this.style.backgroundColor='#0080C0'" onmouseout="this.style.backgroundColor=''">
<font style="float: left; margin-left: 20px; font-size: 12px;">推荐</font></li>
<li style="width: 107px;" onmouseover="this.style.backgroundColor='#0080C0'" onmouseout="this.style.backgroundColor=''">
<font style="float: left; margin-left: 20px; font-size: 12px;">面试</font></li>
<li style="width: 107px;" onmouseover="this.style.backgroundColor='#0080C0'" onmouseout="this.style.backgroundColor=''">
<font style="float: left; margin-left: 20px; font-size: 12px;">offer</font></li>
<li style="width: 107px;" onmouseover="this.style.backgroundColor='#0080C0'" onmouseout="this.style.backgroundColor=''">
<font style="float: left; margin-left: 20px; font-size: 12px;">录用</font></li>
</ul>
</div>
</div>
</td>
<td width="20%">
<div class="menu" id="menu_2" onclick="keepMenu(this)" align="left" style="display:none;">
<a href="http://www.yesky.com/">天极网</a><br>
<a href="http://www.cfan.cn.net/">电脑爱好者</a><br>
<a href="http://www.intoweb.com.cn/">上网杂志</a>
</div>
</td>
<td width="20%">
<div class="menu" id="menu_3" onclick="keepMenu(this)" align="left" style="display:none;">
<a href="http://www.163.com/">163电子邮件</a><br>
<a href="http://freemail.263.net/">首都在线</a><br>
<a href="http://www.21cn.com/">21CN电子邮件</a><br>
<a href="http://www.chinese.com/">炎皇在线</a>
</div>
</td>
<td width="20%">
<div class="menu" id="menu_4" onclick="keepMenu(this)" align="left" style="display:none;">
<a href="http://www.sohu.com.cn/">搜狐</a><br>
<a href="http://www.yahoo.com/">雅虎</a><br>
<a href="http://www.cseek.com/">搜索客</a><br>
<a href="http://www.sina.com/">新浪网</a><br>
<a href="http://202.102.4.31/51windows/js/httP;//www.cqcas.edu.cn/user /sailing">远航网站</a>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</form>
</body>
</html>
zhanglongjason 2010-09-21
  • 打赏
  • 举报
回复
我想实现这个效果
zhanglongjason 2010-09-21
  • 打赏
  • 举报
回复
这个代码我放在网站里面测试怎么不行啊,http://www.68css.com/css_example/752.shtml
lishuai1030 2010-09-21
  • 打赏
  • 举报
回复
偶是路过的
yasire 2010-09-21
  • 打赏
  • 举报
回复
你还是跟踪一下js脚本吧,看看第一次点击怎么执行的,和第二次有什么区别。
MSDNXGH 2010-09-21
  • 打赏
  • 举报
回复
不明白,代码太多了,,,眼又花了。///
MSDNXGH 2010-09-21
  • 打赏
  • 举报
回复
在点。。。。这个是什么意思啊????

62,272

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧