鼠标放上去显示大图片

<SCRIPT LANGUAGE="JavaScript">
function getAbsolutePosition(obj)
{
position = new Object();
position.x = 0;
position.y = 0;
var tempobj = obj;
while(tempobj!=null && tempobj!=document.body)
{
if(window.navigator.userAgent.indexOf("MSIE")!=-1)
{
position.x += tempobj.offsetLeft;
position.y += tempobj.offsetTop;
}
else if(window.navigator.userAgent.indexOf("Firefox")!=-1)
{
position.x += tempobj.offsetLeft;
position.y += tempobj.offsetTop;
}
tempobj = tempobj.offsetParent
}
return position;
}
function show(obj)
{
var img = document.getElementById("showimg");
var pos=getAbsolutePosition(obj);
if(img.src!=obj.src)
{
img.src=obj.src;
}
img.style.display="";
img.style.position="absolute";
img.style.top = pos.y;
img.style.left = pos.x+obj.width;
}
function hide()
{
document.getElementById("showimg").style.display="none";
}
</SCRIPT>

 

<img src="1.jpg" onmouseover="show(this)" onmouseout="hide()" width=50 height=50><BR>
<img src="2.jpg" onmouseover="show(this)" onmouseout="hide()" width=50 height=50><BR>
<img src="3.jpg" onmouseover="show(this)" onmouseout="hide()" width=50 height=50><BR>
<img src="4.jpg" onmouseover="show(this)" onmouseout="hide()" width=50 height=50><BR>
<img src="" id="showimg" style="display:none" height=200>

posted @ 2009-12-22 09:02  Hellen.Li  阅读(750)  评论(0编辑  收藏  举报