这个代码是模仿淘宝网的商品详细页,当你把鼠标放在图片上方时,显示大图的代码。 <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> <div id="Layer1" style="display:none;position:absolute;z-index:1;"></div> <img src="http://pic.sj33.cn/images/logo.gif" onmouseout="hiddenPic();" onmousemove="showPic(this.src);" /> <p></p> </body> </html> (责任编辑:熊猫蜀黍) |