200分200分求一简单问题.

wangyanyan 2006-10-18 01:44:22
当鼠标放到"切换"上出现一层,鼠标移走时消失,下面是我的代码,我这个不能给"网易加连接",还有就是不是弹出一层,还有就是还没等到鼠标放到层上就消失了.你可在我基础上改,也可以给我一个代码.


function toggle(el){
if(typeof(el)=="string"){el=document.getElementById(el);}
if(el.style.display!=""){el.style.display="";return}
if(el.style.display!="none"){el.style.display="none";return}
el.style.left = event.x-5;
el.style.top = event.y-10;
el.style.visibility = 'visible';
}

document.writeln(" <td id=\"s_td_1\" width=\"117\" class=\"f-12-000\" onmouseover=toggle('n1');>切换<\/td>");
document.writeln(" <\/tr>");
document.writeln("<\/table>")
document.writeln("<div id=\"n1\" style=\"display:none;text-align:right;\">网易 新浪<\/div>")
...全文
573 40 打赏 收藏 转发到动态 举报
写回复
用AI写文章
40 条回复
切换为时间正序
请发表友善的回复…
发表回复
luck0235 2006-10-20
  • 打赏
  • 举报
回复
这个是CSDN“结帖”功能代码,鼠标指向时,显示可给分数和已给分数,鼠标移开时,层关闭,楼主可参考:

<!--ASPX页面先定义一个隐藏的层-->
<body>
<div id="scoreLayer" style="DISPLAY: none; FONT-SIZE: 13px; Z-INDEX: 99; BACKGROUND: #ffff00; WIDTH: 120px; POSITION: absolute"></div>
......


//鼠标指向时
function myOnMouseOver(e)
{
//其它略,只写了显示层的部分代码......
//获取层
var cen = document.getElementById("scoreLayer");
//设置层背景色
cen.style.background = "#FFFF00";
//设置层中内容
cen.innerText = "该问题总分值:"+ zong +"\r\n现可给的分值:"+ n;

//层显示
var eTop = e.offsetTop;
var eLeft= e.offsetLeft;
var h = e.clientHeight;
var w = e.clientWidth;
while (e = e.offsetParent)
{
eTop += e.offsetTop;
eLeft += e.offsetLeft;
}
cen.style.display = "";
cen.style.top = eTop + h;
cen.style.left= eLeft + w - cen.clientWidth;
}

//鼠标离开时
function myOnMouseOut()
{
document.getElementById("scoreLayer").style.display = "none";
}
股神 2006-10-19
  • 打赏
  • 举报
回复
up
懒是一种态度 2006-10-19
  • 打赏
  • 举报
回复
顶一下
hawk5456 2006-10-19
  • 打赏
  • 举报
回复
不错
fengkoulangjian 2006-10-19
  • 打赏
  • 举报
回复
关注
股神 2006-10-18
  • 打赏
  • 举报
回复
来顶.0..
Radar2006 2006-10-18
  • 打赏
  • 举报
回复
up
avisnet 2006-10-18
  • 打赏
  • 举报
回复
下面这个点击层上的按钮后关闭

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Untitled Page</title>
<script type="text/jscript">
function show(e) {
if(typeof(e) == "string") {
e = document.getElementById(e);
}
e.style.position = 'absolute';
e.style.left = event.x - 5;
e.style.right = event.y - 10;
e.style.display = 'block';
}
function hide(e) {
if(typeof(e) == "string") {
e = document.getElementById(e);
}
e.style.display = 'none';
}
</script>
</head>
<body>
<form id="form1" runat="server">
<table>
<tr>
<td onmouseover="show('win')" width="80" bgcolor="lime">切换</td>
</tr>
</table>
<div id="win" style="display:none; width:100px; height:100px; background-color:Beige">
<div style="position:absolute; width:16px; height:16px; left:80px; top:4px; cursor:hand" onclick="hide('win')">x</div>
</div>
</form>
</body>
</html>
Csharp110 2006-10-18
  • 打赏
  • 举报
回复
学习了!
seesharp 2006-10-18
  • 打赏
  • 举报
回复
mark
也想知道怎么才能使鼠标移动到层上去而不是鼠标一离开链接 层就消失了
zhouyan024 2006-10-18
  • 打赏
  • 举报
回复
sPop=null;
curShow=null;
tFadeOut=null;
tFadeIn=null;
tFadeWaiting=null;

document.write("<style type='text/css'id='defaultPopStyle'>");
document.write(".cPopText { background-color: #F8F8F5;color:#000000; border: 1px #000000 solid;font-color: font-size: 12px; padding-right: 4px; padding-left: 4px; height: 20px; padding-top: 2px; padding-bottom: 2px; filter: Alpha(Opacity=0)}");
document.write("</style>");
document.write("<div id='dypopLayer' style='position:absolute;z-index:1000;' class='cPopText'></div>");


function showPopupText(){
var o=event.srcElement;
MouseX=event.x;
MouseY=event.y;
if(o.alt!=null && o.alt!=""){o.dypop=o.alt;o.alt=""};
if(o.title!=null && o.title!=""){o.dypop=o.title;o.title=""};
if(o.dypop!=sPop) {
sPop=o.dypop;
clearTimeout(curShow);
clearTimeout(tFadeOut);
clearTimeout(tFadeIn);
clearTimeout(tFadeWaiting);
if(sPop==null || sPop=="") {
dypopLayer.innerHTML="";
dypopLayer.style.filter="Alpha()";
dypopLayer.filters.Alpha.opacity=0;
}
else {
if(o.dyclass!=null) popStyle=o.dyclass
else popStyle="cPopText";
curShow=setTimeout("showIt()",tPopWait);
}

}
}

function showIt(){
dypopLayer.className=popStyle;
dypopLayer.innerHTML=sPop;
popWidth=dypopLayer.clientWidth;
popHeight=dypopLayer.clientHeight;
if(MouseX+12+popWidth>document.body.clientWidth) popLeftAdjust=-popWidth-24
else popLeftAdjust=0;
if(MouseY+12+popHeight>document.body.clientHeight) popTopAdjust=-popHeight-24
else popTopAdjust=0;
dypopLayer.style.left=MouseX+12+document.body.scrollLeft+popLeftAdjust;
dypopLayer.style.top=MouseY+12+document.body.scrollTop+popTopAdjust;
dypopLayer.style.filter="Alpha(Opacity=0)";
fadeOut();
}

function fadeOut(){
if(dypopLayer.filters.Alpha.opacity<popOpacity) {
dypopLayer.filters.Alpha.opacity+=showPopStep;
tFadeOut=setTimeout("fadeOut()",1);
}
else {
dypopLayer.filters.Alpha.opacity=popOpacity;
tFadeWaiting=setTimeout("fadeIn()",tPopShow);
}
}

function fadeIn(){
if(dypopLayer.filters.Alpha.opacity>0) {
dypopLayer.filters.Alpha.opacity-=1;
tFadeIn=setTimeout("fadeIn()",1);
}
}
document.onmouseover=showPopupText;
</SCRIPT>
</HEAD>
qixiao 2006-10-18
  • 打赏
  • 举报
回复
up
fd7893 2006-10-18
  • 打赏
  • 举报
回复
mark
dinoLgrace 2006-10-18
  • 打赏
  • 举报
回复
up
wolfdragon 2006-10-18
  • 打赏
  • 举报
回复
改了一下,不过你要自己设定停留时间才行

function toggle(el){
if(typeof(el)=="string"){el=document.getElementById(el);}
if(el.style.display!=""){el.style.display="";return}
if(el.style.display!="none"){el.style.display="none";return}
el.style.left = event.x-5;
el.style.top = event.y-10;
el.style.visibility = 'visible';
}

document.writeln(" <table> <td id=\"s_td_1\" width=\"117\" class=\"f-12-000\" onmouseover=toggle('n1');>切换<\/td>");
document.writeln(" <\/tr>");
document.writeln("<\/table>")
document.writeln("<div id=\"n1\" style=\"display:none;text-align:right;\"><a href=\"http://www.163.com\">网易</a> <a href=\"http:www.sina.com\">新浪</a><\/div>")



dino815613 2006-10-18
  • 打赏
  • 举报
回复
同意sunjay117(我是一只鸡),我用过这个,完全可以啊!
fencole 2006-10-18
  • 打赏
  • 举报
回复
up
jedliu 2006-10-18
  • 打赏
  • 举报
回复
q:那个方法是不错:可以你永远点不开连接啊???
因为当你的鼠标移开时,就消失了呀....

a:有理!实验先!
X27794797 2006-10-18
  • 打赏
  • 举报
回复
效果还行,我有个兼容类似的效果,但是现在家里电脑出问题。。。。。
gezichong 2006-10-18
  • 打赏
  • 举报
回复
想要点开连接,,我感觉要把onmouseleave函数去掉才可以的...
加载更多回复(20)

62,041

社区成员

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

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

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

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