鼠標移動到名(wait
gif)上
顯示圖片
鼠標移開則不顯示圖片
做法新建 ahtml 和 一個待顯示圖片 waitgif 放在同一目錄下
ahtml 代碼如下
復制代碼 代碼如下:
<!DOCTYPE HTML PUBLIC "
//W
C//DTD HTML
Transitional//EN"
"
<html>
<head>
<title></title>
<script type="text/javascript">
var path =
/
; //圖片相對路徑
function show(obj) {
var name = obj
innerText;
var sDiv = document
getElementById(
img_
+ name
split(
)[
]);//文件名自己判斷
if (!sDiv) {
sDiv = document
createElement("DIV");
sDiv
id =
img_
+ name
split(
)[
];
sDiv
style
position =
absolute
;
sDiv
style
top = obj
offsetTop + obj
offsetWidth +
px
;
sDiv
style
left = obj
offsetLeft +obj
offsetHeight +
px
;
sDiv
style
border =
px red solid
;
var img = document
createElement("img");
img
src = path + name;
sDiv
appendChild(img);
document
body
appendChild(sDiv);
}
sDiv
style
display =
block
;
}
function f(obj) {
var name = obj
innerText;
var sDiv = document
getElementById(
img_
+ name
split(
)[
]);//文件名自己判斷
if (sDiv) {
sDiv
style
display =
none
;
}
}
</script>
</head>
<body>
<div onmouseover="show(this)" onmouseout="f(this)" style="position:absolute;">
wait
gif
</div>
</body>
</html>
From:http://tw.wingwit.com/Article/program/Java/JSP/201311/20089.html