码迷,mamicode.com
首页 > 编程语言 > 详细

javascript弹出带文字信息的提示框效果

时间:2017-03-03 19:05:58      阅读:192      评论:0      收藏:0      [点我收藏+]

标签:nav   tool   order   提示框   set   doc   document   lang   lock   

// position of the tooltip relative to the mouse in pixel //

<html>
<head>
<meta charset="utf-8">
<style>
.tableBorder7{width:800;solid; background-color: #000000;}
TD{font-family: 宋体;font-size: 12px;line-height : 15px ;}
th{background-color: #f7f7f7;color: #000000;font-size: 12px;font-weight:bold;}
th.th1{background-color: #333333;}
td.TableBody7{background-color: #B1EA45;}
</style>
<script language="JavaScript">
var offsetx = 12;
var offsety = 8;
function newelement(newid)
{
if(document.createElement)
{
var el = document.createElement(‘div‘);
el.id = newid;
with(el.style)
{
display = ‘none‘;
position = ‘absolute‘;
}
el.innerHTML = ‘ ‘;
document.body.appendChild(el);
}
}
var ie5 = (document.getElementById && document.all);
var ns6 = (document.getElementById && !document.all);
var ua = navigator.userAgent.toLowerCase();
var isapple = (ua.indexOf(‘applewebkit‘) != -1 ? 1 : 0);
function getmouseposition(e)
{
if(document.getElementById)
{
var iebody=(document.compatMode &&
document.compatMode != ‘BackCompat‘) ?
document.documentElement : document.body;
pagex = (isapple == 1 ? 0:(ie5)?iebody.scrollLeft:window.pageXOffset);
pagey = (isapple == 1 ? 0:(ie5)?iebody.scrollTop:window.pageYOffset);
mousex = (ie5)?event.x:(ns6)?clientX = e.clientX:false;
mousey = (ie5)?event.y:(ns6)?clientY = e.clientY:false;
var lixlpixel_tooltip = document.getElementById(‘tooltip‘);
lixlpixel_tooltip.style.left =(mousex+pagex+offsetx) + ‘px‘;
lixlpixel_tooltip.style.top =(mousey+pagey+offsety) + ‘px‘;
}
}
function tooltip(tip)
{
if(!document.getElementById(‘tooltip‘)) newelement(‘tooltip‘);
var lixlpixel_tooltip = document.getElementById(‘tooltip‘);
lixlpixel_tooltip.innerHTML = tip;
lixlpixel_tooltip.style.display = ‘block‘;
document.onmousemove = getmouseposition;
}
function exit()
{
document.getElementById(‘tooltip‘).style.display = ‘none‘;
}
</script>
</HEAD>
<BODY>
<div onmouseover="tooltip(‘如果你添加的是一个播客(Podcast),请选中此复选框。‘);"onmouseout="exit();">蝶恋花</div>
</BODY>
</HTML>

javascript弹出带文字信息的提示框效果

标签:nav   tool   order   提示框   set   doc   document   lang   lock   

原文地址:http://www.cnblogs.com/woodyliang/p/6497904.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!