HTML页面中编写一个提示框,动态定位与提示不同语句
2012-11-24 17:38
232 查看
HTML页面中编写一个提示框,动态定位与提示不同语句,当鼠标经过,显示。移走,就消失。
1.写一个div
2.进行js编写,写一个函数,进行处理。
DIV:
调用:
整个HTML文件:
1.写一个div
2.进行js编写,写一个函数,进行处理。
DIV:
<div style="border:1px dashed #800000; padding:15px;display:none; position:fixed;width:160px;height:300px;background-color:#fdd2c5;font-size:19px;z-index:auto" id="divTips" name="divTips"> </div>
<script language="javascript"> function showTips(event,tips){ x=event.clientX; y=event.clientY; var obj; obj=document.getElementById("divTips"); obj.innerHTML=tips; obj.style.left=x; obj.style.top=y; obj.style.display=""; // document.getElementById("divTips").style.display="block"; } function hiddenTips(){ document.getElementById("divTips").style.display="none"; } </script>
调用:
<div onmouseover="showTips(event,'你好')" onmouseout="hiddenTips();" style="border:1px;background-color:black;width:160px;height:20px;">显示当前的标题</div> <div onmouseover="showTips(event,'你dddddddd好')" onmouseout="hiddenTips();" style="border:1px;background-color:red;width:160px;height:20px;">显示当前的标题</div> <div onmouseover="showTips(event,'你好11111')" onmouseout="hiddenTips();" style="border:1px;background-color:orange;width:160px;height:20px;">显示当前的标题</div>
整个HTML文件:
<!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>无标题文档</title>
<script language="javascript"> function showTips(event,tips){ x=event.clientX; y=event.clientY; var obj; obj=document.getElementById("divTips"); obj.innerHTML=tips; obj.style.left=x; obj.style.top=y; obj.style.display=""; // document.getElementById("divTips").style.display="block"; } function hiddenTips(){ document.getElementById("divTips").style.display="none"; } </script>
</head>
<body>
<div onmouseover="showTips(event,'你好')" onmouseout="hiddenTips();" style="border:1px;background-color:black;width:160px;height:20px;">显示当前的标题</div> <div onmouseover="showTips(event,'你dddddddd好')" onmouseout="hiddenTips();" style="border:1px;background-color:red;width:160px;height:20px;">显示当前的标题</div> <div onmouseover="showTips(event,'你好11111')" onmouseout="hiddenTips();" style="border:1px;background-color:orange;width:160px;height:20px;">显示当前的标题</div>
<div onmouseover="showTips('你好22222')" onmouseout="hiddenTips();" style="border:1px;background-color:black;width:160px;height:20px;">显示当前的标题</div>
<div onmouseover="showTips('你好33333')" onmouseout="hiddenTips();" style="border:1px;background-color:black;width:160px;height:20px;">显示当前的标题</div>
<div onmouseover="showTips('你好44444')" onmouseout="hiddenTips();" style="border:1px;background-color:black;width:160px;height:20px;">显示当前的标题</div>
<div style="left:100px; top:3000;">test</div>
<div
style="border:1px dashed #800000; padding:15px;display:none;
position:fixed;width:160px;height:300px;background-color:#fdd2c5;font-size:19px;z-index:auto" id="divTips" name="divTips">
</div>
</body>
</html>
相关文章推荐
- 使Eclipse下支持编写HTML/JS/CSS/JSP页面的自动提示。
- 使Eclipse下支持编写HTML/JS/CSS/JSP页面的自动提示
- 使Eclipse下支持编写HTML/JS/CSS/JSP页面的自动提示。
- 配置Eclipse编写HTML/JS/CSS/JSP页面的自动提示
- 使Eclipse下支持编写HTML/JS/CSS/JSP页面的自动提示
- 使Eclipse下支持编写HTML/JS/CSS/JSP页面的自动提示
- 使Eclipse下支持编写HTML/JS/CSS/JSP页面的自动提示。
- html跳转到同一个页面的不同位置
- 在HTML页面中点不同按钮在同一个IFRAME分别切换不同子页面的方法
- 使Eclipse下支持编写HTML/JS/CSS/JSP页面的自动提示。
- requireJS在同一个HTML/JSP页面,加载不同版本的jquery
- 使Eclipse下支持编写HTML/JS/CSS/JSP页面的自动提示(转)
- 使Eclipse下支持编写HTML/JS/CSS/JSP页面的自动提示
- 使Eclipse下支持编写HTML/JS/CSS/JSP页面的自动提示
- 使Eclipse下支持编写HTML/JS/CSS/JSP页面的自动提示
- 使Eclipse下支持编写HTML/JS/CSS/JSP页面的自动提示。
- 使Eclipse下支持编写HTML/JS/CSS/JSP页面的自动提示
- 使Eclipse下支持编写HTML/JS/CSS/JSP页面的自动提示。
- 使Eclipse下支持编写HTML/JS/CSS/JSP页面的自动提示
- 使Eclipse下支持编写HTML/JS/CSS/JSP页面的自动提示。