<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(image, width, height) <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] - width/2; <BR>newdiv.style.posTop = absPos[1] - 高さ/2; <BR>newdiv.style.display="ブロック"; <BR>} <BR>関数 HideElement(id) <BR>{ <BR>var elem = document.getElementById(id); <BR>elem.style.display="none"; <BR>} <BR></script>
例:
< ;本体>