如何实现弹出提示

idealTorch 2006-10-09 10:27:19
想制作一个类似csdn结帖给分的提示,但是只需要提示就可以,不用象csdn那样需要计算。在csdn的代码里修改,总是出错,请大家指明。代码如下

<html>
<head>
<script language=JavaScript>

var cen = document.all.pop;

function cc()
{
cen.style.background = "#FF0000";
cen.innerText ="现可给的分值:";
var ttop = e.offsetTop;
var tleft= e.offsetLeft;
var h = e.clientHeight; //在下面这个 while 循环里的e已经不是那个形参了
var w = e.clientWidth;

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

}
</script>
</head>

<body>
<input name="Mo" type="text" id="Mo" maxlength="18" onmouseover="cc()">
</body>
</html>
...全文
104 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
xiongzai 2006-10-09
  • 打赏
  • 举报
回复
你沒有把對象傳進去,而且你的JS引用了一個不存在的對象,那肯定會出錯
xiongzai 2006-10-09
  • 打赏
  • 举报
回复
<html>
<head>

</head>

<body>
<div id="pop" style="position: absolute; width: 120; display: none; z-index: 99;
font-size: 13px; background: #ffff00">
</div>
<script language=JavaScript>

var cen = document.all.pop;

function cc(e)
{
cen.style.background = "#FF0000";
cen.innerText ="现可给的分值:";

var ttop = e.offsetTop;
var tleft= e.offsetLeft;
var h = e.clientHeight; //在下面这个 while 循环里的e已经不是那个形参了
var w = e.clientWidth;

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

}
</script>
<input name="Mo" type="text" id="Mo" maxlength="18" onmouseover="cc(this)">
</body>
</html>
liangjianshi 2006-10-09
  • 打赏
  • 举报
回复
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>鼠标提示</title>
<script language="JavaScript">
function seashowtip(tips,flag,iwidth){
var my_tips=document.all.mytips;
if(flag){
my_tips.innerHTML=tips;
my_tips.style.display="";
my_tips.style.width=iwidth;
my_tips.style.left=event.clientX+10+document.body.scrollLeft;
my_tips.style.top=event.clientY+10+document.body.scrollTop;
}
else
{
my_tips.style.display="none";
}
}
</script>
<style>
body{font-size:12px}
</style>
<div id=mytips style="position:absolute;background-color:#FFF8DC;width:121;height:16;border:1px solid gray;display:none;filter: progid:DXImageTransform.Microsoft.Shadow(color=#FF9900,direction=135,strength=3); left:0; top:5"></div>
</head>
<body>
<form name="form1" method="post" action="">
用户名:
<input type="text" name="textfield" tips="*** 输入用户名." onmousemove=seashowtip(this.tips,1,150) onmouseout=seashowtip(this.tips,0,150) onclick=seashowtip(this.tips,0,150)>
<input type="submit" name="Submit" value="提交"><br/>
</form>
</body>
</html>

87,922

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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