1
<html>
2
<head>
3
<title>tip</title>
4
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
5
</head>
6
<body>
7
<script>
8
if(!document.attachEvent)
9
{
10
document.attachEvent = function(){document.addEventListener(arguments[0].substr(2),arguments[1],arguments[2])}
11
}
12
document.attachEvent("onmouseover",function(e)
13
{
14
var tip = "";
15
if(typeof(event)=="undefined"){
16
tip = e.target.getAttribute("tips")
17
}else{
18
e = event;
19
tip = e.srcElement.tips;
20
}
21
if(typeof(tip)!="undefined"&&tip.length>0)
22
{
23
var _tips = document.getElementById("myTip");
24
if(typeof(_tips)=="undefined"||_tips == null)
25
{
26
_tips = document.createElement("div");
27
_tips.id = "myTip";
28
_tips.style.position = "absolute";
29
_tips.style.width = "150px";
30
_tips.style.borderWidth = "1px";
31
_tips.style.borderStyle = "solid";
32
_tips.style.borderColor = "gray";
33
_tips.style.fontSize = "9pt";
34
_tips.style.backgroundColor = "#ffffff";
35
_tips.style.color = "#349045";
36
_tips.style.filter = "progid:DXImageTransform.Microsoft.Shadow(color=#999999,direction=135,strength=3)";
37
_tips.style.padding = "5px 8px 3px 8px";
38
document.body.appendChild(_tips);
39
_tips.style.display = "none";
40
}
41
_tips.style.display = "";
42
_tips.innerHTML = tip;
43
_tips.style.left = document.body.scrollLeft+e.clientX+10;
44
_tips.style.top = document.body.scrollTop+e.clientY+10;
45
}
46
}
47
);
48
document.attachEvent('onmouseout',function(e)
49
{
50
var _tips = document.getElementById("myTip");
51
if(_tips!=null)
52
{
53
_tips.style.display="none";
54
}
55
}
56
)
57
</script>
58
<a href="#" tips="自定義提示" >測試鏈接</a>
59
<a href="#" tips="<h1>你好世界</h1>">測試鏈接</a>
60
<a href="#" tips="這里填寫tips">測試鏈接</a>
61
62
</body>
63
</html>
最終代碼預覽
2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

http://dev.mobai.org/js/JS_Tags_Tips.html
沒有所謂的命運,只有不同的選擇!