编辑器加载中...<script>
function GetAbsPosition(obj) { var curleft = 0, curtop = 0; do { curleft += obj.offsetLeft; curtop += obj.offsetTop; } while (obj = obj.offsetParent); return [curleft,curtop]; } function ShowFloatingImage(image, width, height) { var id = "trailimageid"; var newdiv = document.getElementById(id); if(newdiv == null) { newdiv = document.createElement('div'); newdiv.setAttribute('id',id); newdiv.setAttribute('onmouseout', "HideElement('"+id+"');"); document.body.appendChild(newdiv); } newdiv.innerHTML = '<img src='+image.src+ ' width='+(image.width + width) + ' height=' + (image.height + height) + ' />'; var absPos = GetAbsPosition(image); newdiv.style.position = "absolute"; newdiv.style.posLeft = absPos[0] - width/2; newdiv.style.posTop = absPos[1] - height/2; newdiv.style.display="block"; } function HideElement(id) { var elem = document.getElementById(id); elem.style.display="none"; } </script> 例子: <img src="../Pictures/tupian/00070724_m500.jpg" width="300" height="300" οnmοuseοver="ShowFloatingImage(this, 150, 150);" />