<script> <br>함수 GetAbsPosition(obj) <br>{ <br>var curleft = 0, curtop = 0; <br>do { <br>curleft = obj.offsetLeft; <br>curtop = obj.offsetTop; <br>} while(obj = obj.offsetParent); <br>return [curleft,curtop]; <br>} <br>function ShowFloatingImage(이미지, 너비, 높이) <br>{ <br>var id = "trailimageid"; <br>var newdiv = document.getElementById(id); <br>if(newdiv == null) <br>{ <br>newdiv = document.createElement('div'); <br>newdiv.setAttribute('id',id); <br>newdiv.setAttribute('onmouseout', "HideElement('" id "');"); <br>document.body.appendChild(newdiv); <br>} <br>newdiv.innerHTML = '<img src=' image.src ' width=' (image.width 너비) ' height=' (image.height 높이) ' />'; <br>var absPos = GetAbsPosition(이미지); <br>newdiv.style.position = "절대"; <br>newdiv.style.posLeft = absPos[0] - 너비/2; <br>newdiv.style.posTop = absPos[1] - 높이/2; <br>newdiv.style.display="차단"; <br>} <br>function HideElement(id) <br>{ <br>var elem = document.getElementById(id); <br>elem.style.display="없음"; <br>} <br></script>
例子:
< ;몸>
经测试事件处理的不是很好。导致鼠标移开不能回到原位。