<!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=gb2312" /> <title>無標題文檔</title> <script language="javascript"> function addmethod() { var table=document.getElementById("table"); var tr=table.firstChild.getElementsByTagName("tr")[0]; var arr=tr.getElementsByTagName("td"); for (var i=0;i<arr.length;i++) { arr[i].firstChild.attachEvent("onmousemove",showdiv); arr[i].firstChild.attachEvent("onmouseout",hiddendiv); } } function showdiv() { var div=document.getElementById("Layer1"); var image=document.getElementById("image"); image.setAttribute("src",window.event.srcElement.src); div.style.top=window.event.clientY+5; div.style.left=window.event.clientX+5; div.style.visibility="visible"; } function hiddendiv() { var div=document.getElementById("Layer1"); div.style.visibility="hidden"; } </script> <style type="text/css"> <!-- #Layer1 { position:absolute; left:221px; top:250px; width:165px; height:114px; z-index:1; visibility:hidden; } --> </style> </head> <body onload="addmethod()"> <table id="table" width="768" border="1"> <tr> <td></td> <td></td> <td></td> </tr> </table> <div id="Layer1"></div> </body> </html>
[Ctrl+A 全選 注:如需引入外部Js需重新整理才能執行]