<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>JS函數實現鼠標指向圖片後顯示大圖</title> <script language="javascript"> function showPic(sUrl){ var x,y; x = event.clientX; y = event.clientY; document.getElementById("Layer1").style.left = x; document.getElementById("Layer1").style.top = y; document.getElementById("Layer1").innerHTML = "<img src=\"" + sUrl + "\">"; document.getElementById("Layer1").style.display = "block"; } function hiddenPic(){ document.getElementById("Layer1").innerHTML = ""; document.getElementById("Layer1").style.display = "none"; } </script> </head> <body> <P id="Layer1" style="display:none;position:absolute;z-index:1;"></P> <img src="/images/logo.gif" onmouseout="hiddenPic();" onmousemove="showPic(this.src);" /> <p></p> </body> </html>
[Ctrl+A 全部選擇 提示:你可先修改部分代碼,再按運行]