本文实例讲述了javascript实现的图片预览功能。分享给大家供大家参考,具体如下:
1.将下面的代码复制到
内
/*
Thumbnail image viewer-
?Dynamic Drive (www.dynamicdrive.com)
For full source code,usage terms,and 100's more DHTML scripts,visit http://dynamicdrive.com
*/
function enlarge(which,e){
//Render image code for IE 4+
if (document.all){
if (showimage.style.visibility=="hidden"){
showimage.style.left=document.body.scrollLeft+event.clientX
showimage.style.top=document.body.scrollTop+event.clientY
showimage.innerHTML='502_0@')
document.showimage.document.close()
document.showimage.left=e.x
document.showimage.top=e.y
document.showimage.visibility="show"
}
else
document.showimage.visibility="hide"
return false
}
//if NOT IE 4+ or NS 4,simply display image in full browser window
else
return true
}