<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
<!--
*{
padding:0px;
margin:0px;
}
#div1 {
height: 200px;
width: 900px;
position:relative;
}
#divsh {
height:410px;
width:410px;
position:absolute;
display:none;
overflow:hidden;
}
#divsh img{
width:400px;
height:400px;
border:1px #5D5D5D solid;
}
#box{
margin-left:100px;
}
-->
</style>
<script type="text/javascript">
var timer;
function setmouse(e){
var o1=document.getElementById("div1");
var imgs=o1.getElementsByTagName("img");
for(var i=0;i<imgs.length;i++){
imgs[i].οnmοusemοve=function(){
xy(e);
}
imgs[i].οnmοuseοver=function(){
fangda(this);
}
imgs[i].οnmοuseοut=out;
}
}
function xy(e){
var mx,my;
mx=showPos(e).x;
my=showPos(e).y;
document.getElementById("mx").value=mx;
document.getElementById("my").value=my;
var o1,o2;
o1=document.getElementById("div1");
o2=document.getElementById("divsh");
o2.style.left=showPos(e).x-parseInt(o1.offsetLeft)+5+"px";
o2.style.top=showPos(e).y-parseInt(o1.offsetTop)+5+"px";
}
function showPos(e){
e=e||window.event;
var x,y;
return{
x:e.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,
y:e.clientY+document.body.scrollTop+document.documentElement.scrollTop
}
}
function fangda(which){
var s,n,bigS,show,bigImg;
var w,h;
show=document.getElementById("divsh");
show.style.display="block";
s=which.src;
n=parseInt(s.substring(s.lastIndexOf("/")+4))
bigImg=document.createElement("img");
bigS="images/b"+n+".jpg";
bigImg.src=bigS;
show.appendChild(bigImg);
bigImg.style.width="400px";
bigImg.style.height="400px";
show.style.width="400px";
show.style.height="0px";
var change=function(){
h=parseInt(show.style.height);
if( h<400){
show.style.height=(h+(400-h)/10)+"px";
}
}
//e=e||window.event;
// bigImg.style.width="0px";
// bigImg.style.height="0px";
// var change=function(){
// w=parseInt(bigImg.style.width);
// h=parseInt(bigImg.style.height);
// if( w<400||h<400){
// bigImg.style.width=(w+(400-w)/10)+"px";
// bigImg.style.height=(w+(400-w)/10)+"px";
// }
// }
timer=setInterval(change,10);
}
function out(){
var show=document.getElementById("divsh");
var imgs=show.getElementsByTagName("img");
show.style.display="none";
for(var i=0;i<imgs.length;i++){
show.removeChild(imgs[i]);
}
window.clearInterval(timer);
}
window.οnlοad=function(){
setmouse();
}
</script>
</head>
<body>
<div id="box">
<div id="inp">鼠标X轴:<input type="text" id="mx" class="btn"/>鼠标Y轴:<input type="text" id="my" class="btn"/></div>
<div id="div1"><img src="images/r_s1.jpg" width="200" height="200" /><img src="images/r_s2.jpg" width="200" height="200" />
<div id="divsh"></div></div>
</div>
</body>
</html>