<html> |
<head> |
<title>跟随鼠标的图像</title> |
</head> |
<body> |
<script language= "JavaScript" > |
var newtop=0 |
var newleft=0 |
layerStyleRef= "layer.style." ; |
layerRef= "document.all" ; |
styleSwitch= ".style" ; |
function doMouseMove() |
{ |
layerName = 'picture' |
eval( 'var curElement=' +layerRef+ '["' +layerName+ '"]' ) |
eval(layerRef+ '["' +layerName+ '"]' +styleSwitch+ '.visibility="hidden"' ) |
eval( 'curElement' +styleSwitch+ '.visibility="visible"' ) |
eval( 'newleft=document.body.clientWidth-curElement' +styleSwitch+ '.pixelWidth' ) |
eval( 'newtop=document.body.clientHeight-curElement' +styleSwitch+ '.pixelHeight' ) |
eval( 'height=curElement' +styleSwitch+ '.height' ) |
eval( 'width=curElement' +styleSwitch+ '.width' ) |
width=parseInt(width) |
height=parseInt(height) |
if (event.clientX > (document.body.clientWidth - width)) |
{ |
newleft=document.body.clientWidth + document.body.scrollLeft- width |
} |
else {newleft=document.body.scrollLeft + event.clientX} |
eval( 'curElement' +styleSwitch+ '.pixelLeft=newleft' ) |
if (event.clientY > (document.body.clientHeight - height)) |
{ |
newtop=document.body.clientHeight + document.body.scrollTop - height |
} |
else |
{ |
newtop=document.body.scrollTop + event.clientY |
} |
eval( 'curElement' +styleSwitch+ '.pixelTop=newtop' ) |
} |
document.onmousemove = doMouseMove; |
document.write( "<img ID=picture src='pic01.gif' Style='position:absolute;TOP:0pt;LEFT:0pt;Z-INDEX:2; visibility:hidden;'>" ); |
</script> |
</body> |
</html> |