当前位置: 首页 > news >正文

产生title跟随效果

ContractedBlock.gif ExpandedBlockStart.gif Code
//产生title跟随效果
document.write('<div id="pltsTipLayer" name="pltsTipLayer" style="display: none;position: absolute; z-index:10001; text-align:left;"></div>');
var pltsPop=null;
var pltsoffsetX = 10;   // 弹出窗口位于鼠标左侧或者右侧的距离;3-12 合适
var pltsoffsetY = 15;  // 弹出窗口位于鼠标下方的距离;3-12 合适
var pltsPopbg="#FFFFEE"//背景色
var pltsPopfg="#111111"//前景色
var pltsTitle="";
function pltsinits()
{
    document.onmouseover   
= plts;
    document.onmousemove 
= moveToMouseLoc;
}


function plts()
{  
var o=event.srcElement;
    
if(o.alt!=null && o.alt!=""){o.dypop=o.alt;o.alt=""};
    
if(o.title!=null && o.title!=""){o.dypop=o.title;o.title=""};
    pltsPop
=o.dypop;
    
if(pltsPop!=null&&pltsPop!=""&&typeof(pltsPop)!="undefined")
    {
       pltsTipLayer.style.left
=-1000;
       pltsTipLayer.style.display
='';
       
var Msg=pltsPop.replace(/\n/g,"<br>");
       Msg
=Msg.replace(/\0x13/g,"<br>");
       
var re=/\{(.[^\{]*)\}/ig;
       
if(!re.test(Msg))pltsTitle="";
       
else{
         re
=/\{(.[^\{]*)\}(.*)/ig;
           pltsTitle
=Msg.replace(re,"$1")+" ";
         re
=/\{(.[^\{]*)\}/ig;
         Msg
=Msg.replace(re,"");
         Msg
=Msg.replace("<br>","");}
              
var content =
             
'<table style="FILTER:alpha(opacity=90) shadow(color=#bbbbbb,direction=135);" id=toolTipTalbe border=0><tr><td width="100%"><table class=TittableBorder cellspacing="1" cellpadding="0" style="width:100%">'+
             
'<tr><td class=Tit style="padding-left:10px;padding-right:10px;padding-top: 6px;padding-bottom:6px;line-height:135%">'+Msg+'</td></tr>'+
             
'</table></td></tr></table>';
              pltsTipLayer.innerHTML
=content;
              toolTipTalbe.style.width
=Math.min(pltsTipLayer.clientWidth,document.documentElement.clientWidth/2.2);
              moveToMouseLoc();
              
return true;
       }
    
else
    {
           pltsTipLayer.innerHTML
='';
             pltsTipLayer.style.display
='none';
              
return true;
    }
}


function moveToMouseLoc()
{
       
if(pltsTipLayer.innerHTML=='')return true;
       
var MouseX=event.x;
       
var MouseY=event.y;
       
//window.status=event.y;
       var popHeight=pltsTipLayer.clientHeight;
       
var popWidth=pltsTipLayer.clientWidth;
       
if(MouseY+pltsoffsetY+popHeight>document.documentElement.clientHeight)
       {
                popTopAdjust
=-popHeight-pltsoffsetY*1.5;
       }
        
else
       {
                 popTopAdjust
=0;
       }
       
if(MouseX+pltsoffsetX+popWidth>document.documentElement.clientWidth)
       {
              popLeftAdjust
=-popWidth-pltsoffsetX*2;
       }
       
else
       {
              popLeftAdjust
=0;
       }
       pltsTipLayer.style.left
=MouseX+pltsoffsetX+document.documentElement.scrollLeft+popLeftAdjust;
       pltsTipLayer.style.top
=MouseY+pltsoffsetY+document.documentElement.scrollTop+popTopAdjust;
         
return true;
}
pltsinits();

 

使用方法:对象一定要有alt属性,title的值显示为alt值。

转载于:https://www.cnblogs.com/shineqiujuan/archive/2008/12/06/1349257.html

相关文章:

  • 优化MySQL数据库性能的八种方法
  • 云计算将如何改变世界
  • 最近打开网易的邮箱为什么弹出些黄色网站的窗口呢
  • javascript面向对象编程的学习(基础)
  • 怎么在CString的Format函数里包含“%”,也就是用函数输出字符“%”?
  • 看看去年的北京庙会
  • CreatePen
  • jQuery技巧大放送
  • 浅析值类型与引用类型的内存分配
  • 在线抓图WebSnap Beta 1.2 更新
  • 软件开发者面试百问(转)
  • tomcat:Cannot get a connection, pool exhausted
  • 网站架构探索(1)---序言 王泽宾
  • asp.net 给button 控件 换个背景图片
  • VSTDB
  • [原]深入对比数据科学工具箱:Python和R 非结构化数据的结构化
  • docker-consul
  • mysql_config not found
  • MySQL-事务管理(基础)
  • Mysql优化
  • Node 版本管理
  • Redis学习笔记 - pipline(流水线、管道)
  • Sass Day-01
  • Vultr 教程目录
  • 基于Javascript, Springboot的管理系统报表查询页面代码设计
  • 记一次和乔布斯合作最难忘的经历
  • 聊聊spring cloud的LoadBalancerAutoConfiguration
  • 数据可视化之 Sankey 桑基图的实现
  • 我看到的前端
  • 消息队列系列二(IOT中消息队列的应用)
  • 原生Ajax
  • 字符串匹配基础上
  • 《TCP IP 详解卷1:协议》阅读笔记 - 第六章
  • ​Java并发新构件之Exchanger
  • ​queue --- 一个同步的队列类​
  • #预处理和函数的对比以及条件编译
  • (3)llvm ir转换过程
  • (32位汇编 五)mov/add/sub/and/or/xor/not
  • (C语言)求出1,2,5三个数不同个数组合为100的组合个数
  • (M)unity2D敌人的创建、人物属性设置,遇敌掉血
  • (层次遍历)104. 二叉树的最大深度
  • (分享)自己整理的一些简单awk实用语句
  • (附源码)springboot掌上博客系统 毕业设计063131
  • (九十四)函数和二维数组
  • (转)人的集合论——移山之道
  • .form文件_一篇文章学会文件上传
  • .NET 解决重复提交问题
  • .NET(C#) Internals: as a developer, .net framework in my eyes
  • .NETCORE 开发登录接口MFA谷歌多因子身份验证
  • .net项目IIS、VS 附加进程调试
  • @Autowired注解的实现原理
  • @kafkalistener消费不到消息_消息队列对战之RabbitMq 大战 kafka
  • @Service注解让spring找到你的Service bean
  • [ 蓝桥杯Web真题 ]-Markdown 文档解析
  • [ 数据结构 - C++]红黑树RBTree