实现鼠标经过超链时的提示图层

2016-02-19 20:43 12 1 收藏

下面图老师小编要向大家介绍下实现鼠标经过超链时的提示图层,看起来复杂实则是简单的,掌握好技巧就OK,喜欢就赶紧收藏起来吧!

【 tulaoshi.com - Web开发 】

代码如下:
SCRIPT
var oPopup = window.createPopup();
function rdl_doClick(){
var oMessage=document.all("oMessage");
with (oPopup.document.body) {
style.backgroundColor="lightyellow";
style.border="solid black 1px";
innerHTML=oMessage.value;
}
oPopup.show(70, 70, 180, 60);
}
/SCRIPT
  Input id=oMessage size=40 value=点击弹出窗口外面的区域关闭它。 BRBRA onmouseover=rdl_doClick() onmouseout=oPopup.hide(); href="#"显示弹出窗口 /A--------------------------------------------------------------------
STYLE type=text/cssBODY {
 MARGIN-TOP: 0px; FONT-SIZE: 9pt; MARGIN-LEFT: 4px; MARGIN-RIGHT: 0px; FONT-FAMILY: "宋体"
}
A {
 FONT-WEIGHT: 400; FONT-SIZE: 13px; COLOR: black; TEXT-DECORATION: none
}
A:hover {
 FONT-WEIGHT: 400; FONT-SIZE: 13px; COLOR: red; TEXT-DECORATION: underline
}
A:active {
 FONT: 9pt "宋体"; CURSOR: hand; COLOR: #ff0033
}
/STYLE
SCRIPT
function show(tips,flag,url){
var my_tips=document.all.mytips;
if(flag){
    my_tips.style.display="";
    if (url!=null){my_tips.innerHTML="img src='"+url+"'align=left"+tips;}
    else{ my_tips.innerHTML=tips;}
    my_tips.style.left=event.clientX+10;
    my_tips.style.top=event.clientY+10;
   }
else
  {
   my_tips.style.display="none";
   }
}
/SCRIPT
A onmousemove=show(this.tips,1) onmouseout=show(this.tips,0) href="#" tips="自定义提示"测试链接/A A onmousemove="show(this.tips,1,'http://be10.ods.org/51js/images/standard/online_member.gif')" onmouseout=show(this.tips,0) href="#" tips="又一个自定义提示"测试链接/A A onmousemove="show(this.tips,1,'http://be10.ods.org/51js/images/standard/online_moderator.gif')" onmouseout=show(this.tips,0) href="#" tips="中华人民共和国中华人民共和国自定义提示"测试链接/A
div id=mytips style="BORDER-RIGHT: gray 1px solid; BORDER-TOP: gray 1px solid; DISPLAY: none; FONT-SIZE: 9pt; FILTER: progid:DXImageTransform.Microsoft.Shadow(color=#999999,direction=135,strength=3); BORDER-LEFT: gray 1px solid; WIDTH: 150px; COLOR: red; BORDER-BOTTOM: gray 1px solid; POSITION: absolute; HEIGHT: 16px; BACKGROUND-COLOR: #ffffff"/div----------------------------------------------------------------------
SCRIPT language=JavaScript
//***********默认设置定义.*********************
tPopWait=50;//停留tWait豪秒后显示提示。
tPopShow=5000;//显示tShow豪秒后关闭提示
showPopStep=20;
popOpacity=99;
//***************内部变量定义*****************
sPop=null;
curShow=null;
tFadeOut=null;
tFadeIn=null;
tFadeWaiting=null;
document.write("style type='text/css'id='defaultPopStyle'");
document.write(".cPopText {  background-color: #F8F8F5;color:#000000; border: 1px #000000 solid;font-color: font-size: 12px; padding-right: 4px; padding-left: 4px; height: 20px; padding-top: 2px; padding-bottom: 2px; filter: Alpha(Opacity=0)}");
document.write("/style");
document.write("div id='dypopLayer' style='position:absolute;z-index:1000;' class='cPopText'/div");
function showPopupText(){
var o=event.srcElement;
 MouseX=event.x;
 MouseY=event.y;
 if(o.alt!=null && o.alt!=""){o.dypop=o.alt;o.alt=""};        if(o.title!=null && o.title!=""){o.dypop=o.title;o.title=""};
 if(o.dypop!=sPop) {
   sPop=o.dypop;
   clearTimeout(curShow);
   clearTimeout(tFadeOut);
   clearTimeout(tFadeIn);
   clearTimeout(tFadeWaiting);
   if(sPop==null sPop=="") {
    dypopLayer.innerHTML="";
    dypopLayer.style.filter="Alpha()";
    dypopLayer.filters.Alpha.opacity=0;
    }
   else {
    if(o.dyclass!=null) popStyle=o.dyclass
     else popStyle="cPopText";
    curShow=setTimeout("showIt()",tPopWait);
   }
 }
}
function showIt(){
  dypopLayer.className=popStyle;
  dypopLayer.innerHTML=sPop;
  popWidth=dypopLayer.clientWidth;
  popHeight=dypopLayer.clientHeight;
  if(MouseX+12+popWidthdocument.body.clientWidth) popLeftAdjust=-popWidth-24
   else popLeftAdjust=0;
  if(MouseY+12+popHeightdocument.body.clientHeight) popTopAdjust=-popHeight-24
   else popTopAdjust=0;
  dypopLayer.style.left=MouseX+12+document.body.scrollLeft+popLeftAdjust;
  dypopLayer.style.top=MouseY+12+document.body.scrollTop+popTopAdjust;
  dypopLayer.style.filter="Alpha(Opacity=0)";
  fadeOut();
}
function fadeOut(){
 if(dypopLayer.filters.Alpha.opacitypopOpacity) {
  dypopLayer.filters.Alpha.opacity+=showPopStep;
  tFadeOut=setTimeout("fadeOut()",1);
  }
  else {
   dypopLayer.filters.Alpha.opacity=popOpacity;
   tFadeWaiting=setTimeout("fadeIn()",tPopShow);
   }
}
function fadeIn(){
 if(dypopLayer.filters.Alpha.opacity0) {
  dypopLayer.filters.Alpha.opacity-=1;
  tFadeIn=setTimeout("fadeIn()",1);
  }
}
document.onmouseover=showPopupText;

来源:https://www.tulaoshi.com/n/20160219/1624379.html

延伸阅读
在日常使用的控件中,大多数控件的Hint属性都是显示为横的,这样在遇到需要提示很长的文字时就显得不美观,所以有必要把长文字分成几行来显示。方法就是在字符串中间用#13,#13在ASCII码中是回车的代码,程序如下,当但在属性框是不能够这么干的,因为属性框会把#13当成字符来使用: beginLabel1.caption :=垂+#13+直+#13+显+#13+示;...
标签: 办公软件
笔者办公室使用的是只有两个按键的2D鼠标,在阅读较长的Word文档时,笔者习惯用滚轮让文档自动滚动,而2D鼠标没有滚轮,需要不断按键才能翻页,非常不方便。有没有什么办法能用2D鼠标让Word自动翻页呢? 其实,只要使用Word的“宏”功能就能轻松实现自动翻页的功能。首先打开一篇文档,然后点击“工具/宏/宏”打开宏设置窗口(或者按快捷键A...
  unit Unit_Mouse; interface uses   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,   Dialogs, StdCtrls, Menus;  {=======================================================   DESIGN BY :  花好月圆 / 玉面书生   DATE:  ...
标签: Web开发
在网上,我们经常可以看到一些非常实用的拖拽效果,特别是应用于网上购物时,访问者直接就可以把选中的物品拖拽到购物箱或者购物车里,非常方便、有趣。不过大多数人不知道,其实用Dreamweaver中的Behaviors也可以做出同样的效果来。如果你有兴趣,就和我一起来制作一个具有拖拽效果的的购物箱吧! 在做拖拽效果的网页之前,首先我们...
实现步骤: 1.实现整个鼠标框选的几个事件(down、move、up),当鼠标点下记录鼠标框选的起点,鼠标抬起结束操作。 2.以鼠标框选过程中获取的鼠标坐标为基点计算框选的矩形的4点坐标,4点坐标以顺时针方向布点。 3.通过Shape.Path类实现在类上画出此矩形。 代码如下: 代码如下: namespace HostDemo {  public class HostCanvas : Ca...

经验教程

267

收藏

83
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部