修改的一个Title提示
使用:
<a href="#" tips="自定义提示内容" title="标题">测试</a>
JS:
1
2 <script language=JavaScript>
3 if(!document.attachEvent)
4 {
5 document.attachEvent = function(){document.addEventListener(arguments[0].substr(2),arguments[1],arguments[2])}
6 }
7
8 document.attachEvent("onmousemove",function(e)
9 {
10 var MouseX=event.x;
11 var MouseY=event.y;
12 var tip = "";
13 var title="";
14
15 if(typeof(event)=="undefined"){
16 tip = e.target.getAttribute("tips")
17 title = e.target.getAttribute("title")
18 }else{
19 e = event;
20 tip = e.srcElement.tips;
21 title = e.srcElement.title;
22 }
23
24
25 if(typeof(tip)!="undefined"&&tip.length>0)
26 {
27 var _tips = document.getElementById("myTip");
28
29 if(typeof(_tips)=="undefined"||_tips == null)
30 {
31 _tips = document.createElement("div");
32 _tips.id = "myTip";
33 _tips.style.position = "absolute";
34
35 _tips.style.borderWidth = "0px";
36 _tips.style.borderStyle = "solid";
37 _tips.style.borderColor = "gray";
38 _tips.style.fontSize = "9pt";
39 _tips.style.backgroundColor = "#ffffff";
40 _tips.style.color = "#FF0000";
41
42
43 //_tips.style.filter = "progid:DXImageTransform.Microsoft.Shadow(color=#999999,direction=135,strength=3)";
44 _tips.style.padding = "0px 0px 0px 0px";
45
46
47 document.body.appendChild(_tips);
48 _tips.style.display = "none";
49 }
50 if(tip.length>0&&tip.length<50)
51 {
52 _tips.style.width = "100px";
53 }
54 else if(tip.length>50&&tip.length<100)
55 {
56 _tips.style.width = "250px";
57 }
58 else
59 {
60 _tips.style.width = "300px";
61 }
62
63 _tips.style.display = "";
64 var tbstring = "<table id=toolTipTalbe cellspacing=1 cellpadding=1 width='100%' bgcolor=#92B4E7 border=0>";
65 tbstring +="<tr><td height=16 style='FILTER: progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr=#96bffd, EndColorStr=#bedbff)'>";
66 tbstring +="<P><font color='RED'>" + title +"</font></P>";
67 tbstring +="</td></tr>";
68 tbstring +="<tr><td width='100%' valign='top' bgcolor='#ECF2FB' style='PADDING-RIGHT: 1px;PADDING-BOTTOM: 1px'>";
69 tbstring += tip;
70 tbstring +="</td></tr></table>";
71 _tips.innerHTML = tbstring;
72
73 _tips.style.left = e.clientX+10;
74 _tips.style.top = e.clientY+10;
75 // var myTip =document.getElementById('toolTipTalbe');
76
77 //document.write(tb.width);
78 // if(MouseY + myTip.style.width>document.body.clientWidth)
79 //{
80 // _tips.style.left = e.clientX-1000;
81 // _tips.style.top = e.clientY-1000;
82 //}
83 // document.getElementById('Text1').value="MouseY=" + MouseY + " myTip.width=" + tip.length*12/250 +" clientWidth="+document.body.clientWidth;
84 }
85 }
86 );
87
88 document.attachEvent('onmouseout',function(e)
89 {
90 var _tips = document.getElementById("myTip");
91 if(_tips!=null)
92 {
93 _tips.style.display="none";
94 }
95 }
96 )
97
98 </script>
2 <script language=JavaScript>
3 if(!document.attachEvent)
4 {
5 document.attachEvent = function(){document.addEventListener(arguments[0].substr(2),arguments[1],arguments[2])}
6 }
7
8 document.attachEvent("onmousemove",function(e)
9 {
10 var MouseX=event.x;
11 var MouseY=event.y;
12 var tip = "";
13 var title="";
14
15 if(typeof(event)=="undefined"){
16 tip = e.target.getAttribute("tips")
17 title = e.target.getAttribute("title")
18 }else{
19 e = event;
20 tip = e.srcElement.tips;
21 title = e.srcElement.title;
22 }
23
24
25 if(typeof(tip)!="undefined"&&tip.length>0)
26 {
27 var _tips = document.getElementById("myTip");
28
29 if(typeof(_tips)=="undefined"||_tips == null)
30 {
31 _tips = document.createElement("div");
32 _tips.id = "myTip";
33 _tips.style.position = "absolute";
34
35 _tips.style.borderWidth = "0px";
36 _tips.style.borderStyle = "solid";
37 _tips.style.borderColor = "gray";
38 _tips.style.fontSize = "9pt";
39 _tips.style.backgroundColor = "#ffffff";
40 _tips.style.color = "#FF0000";
41
42
43 //_tips.style.filter = "progid:DXImageTransform.Microsoft.Shadow(color=#999999,direction=135,strength=3)";
44 _tips.style.padding = "0px 0px 0px 0px";
45
46
47 document.body.appendChild(_tips);
48 _tips.style.display = "none";
49 }
50 if(tip.length>0&&tip.length<50)
51 {
52 _tips.style.width = "100px";
53 }
54 else if(tip.length>50&&tip.length<100)
55 {
56 _tips.style.width = "250px";
57 }
58 else
59 {
60 _tips.style.width = "300px";
61 }
62
63 _tips.style.display = "";
64 var tbstring = "<table id=toolTipTalbe cellspacing=1 cellpadding=1 width='100%' bgcolor=#92B4E7 border=0>";
65 tbstring +="<tr><td height=16 style='FILTER: progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr=#96bffd, EndColorStr=#bedbff)'>";
66 tbstring +="<P><font color='RED'>" + title +"</font></P>";
67 tbstring +="</td></tr>";
68 tbstring +="<tr><td width='100%' valign='top' bgcolor='#ECF2FB' style='PADDING-RIGHT: 1px;PADDING-BOTTOM: 1px'>";
69 tbstring += tip;
70 tbstring +="</td></tr></table>";
71 _tips.innerHTML = tbstring;
72
73 _tips.style.left = e.clientX+10;
74 _tips.style.top = e.clientY+10;
75 // var myTip =document.getElementById('toolTipTalbe');
76
77 //document.write(tb.width);
78 // if(MouseY + myTip.style.width>document.body.clientWidth)
79 //{
80 // _tips.style.left = e.clientX-1000;
81 // _tips.style.top = e.clientY-1000;
82 //}
83 // document.getElementById('Text1').value="MouseY=" + MouseY + " myTip.width=" + tip.length*12/250 +" clientWidth="+document.body.clientWidth;
84 }
85 }
86 );
87
88 document.attachEvent('onmouseout',function(e)
89 {
90 var _tips = document.getElementById("myTip");
91 if(_tips!=null)
92 {
93 _tips.style.display="none";
94 }
95 }
96 )
97
98 </script>