<!DOCTYPE html PUBLIC "//WC//DTD XHTML Transitional//EN" "
<html xmlns="
<head>
<meta http
equiv="Content
Type" content="text/html; charset=utf
" />
<title>可愛的鼠標跟隨</title>
<style>
html{ background:#
;}
body
html
input{ cursor:none;}
body
html{ height:
%;}
#cursor{ position:absolute; left:
px; top:
px; display:block;}
</style>
<script>
window
onload = function(){
var oCursor = document
getElementById("cursor");
document
onmousemove=function (ev){
var oEvent=ev||event
oWidth = document
documentElement
clientWidth
oHeight = document
documentElement
clientHeight
scrollTop=document
documentElement
scrollTop + oEvent
clientY
scrollLeft=document
documentElement
scrollLeft + oEvent
clientX;
if(scrollTop > oHeight
oCursor
offsetHeight){
oCursor
style
top = oHeight
oCursor
offsetHeight+
px
;
}else if(scrollTop <
){
oCursor
style
top =
;
}else{
oCursor
style
top = scrollTop+
px
;
}
if(scrollLeft > oWidth
oCursor
offsetWidth){
oCursor
style
left = oWidth
oCursor
offsetWidth+
px
;
}else{
oCursor
style
left = scrollLeft+
px
;
}
document
onmousedown = function(){
oCursor
innerHTML = "<img src=
/>";
return false;
}
document
onmouseup = function(){
oCursor
innerHTML = "<img src=
/>";
}
};
}
</script>
</head>
<body>
<div id="cursor"><img src="
<input type="button" style="font
size:
px; margin:
px;" value="點擊" onclick="window
open(
)" />
</body>
</html>
From:http://tw.wingwit.com/Article/program/Java/JSP/201311/20597.html