国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > JS > 正文

javascript實現(xiàn)的圖片預覽功能

2024-05-06 16:36:11
字體:
供稿:網(wǎng)友

本文實例講述了javascript實現(xiàn)的圖片預覽功能。分享給大家供大家參考,具體如下:

1.將下面的代碼復制到<head>內(nèi)

<script>/*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.clientXshowimage.style.top=document.body.scrollTop+event.clientYshowimage.innerHTML='<img src="'+which+'">'showimage.style.visibility="visible"}elseshowimage.style.visibility="hidden"return false}//Render image code for NS 4else if (document.layers){if (document.showimage.visibility=="hide"){document.showimage.document.write('<a href="#" rel="external nofollow" onMouseover="drag_dropns(showimage)"><img src="'+which+'" border=0></a>')document.showimage.document.close()document.showimage.left=e.xdocument.showimage.top=e.ydocument.showimage.visibility="show"}elsedocument.showimage.visibility="hide"return false}//if NOT IE 4+ or NS 4, simply display image in full browser windowelsereturn true}</script><script language="Javascript1.2">//By Dynamicdrive.com//drag drop function for NS 4/////////////////////////////////////var nsxvar nsyvar nstempfunction drag_dropns(name){temp=eval(name)temp.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP)temp.onmousedown=gonstemp.onmousemove=dragnstemp.onmouseup=stopns}function gons(e){temp.captureEvents(Event.MOUSEMOVE)nsx=e.xnsy=e.y}function dragns(e){temp.moveBy(e.x-nsx,e.y-nsy)return false}function stopns(){temp.releaseEvents(Event.MOUSEMOVE)}//drag drop function for IE 4+/////////////////////////////////////var dragapproved=falsefunction drag_dropie(){if (dragapproved==true){document.all.showimage.style.pixelLeft=tempx+event.clientX-iexdocument.all.showimage.style.pixelTop=tempy+event.clientY-ieyreturn false}}function initializedragie(){if (event.srcElement.parentElement.id=="showimage"){iex=event.clientXiey=event.clientYtempx=showimage.style.pixelLefttempy=showimage.style.pixelTopdragapproved=truedocument.onmousemove=drag_dropie}}if (document.all){document.onmousedown=initializedragiedocument.onmouseup=new Function("dragapproved=false")}</script>

2.在<body>中加入

復制代碼 代碼如下:
<div id="showimage" style="position:absolute;visibility:hidden"></div>

 

3.在連接圖片的地方這樣寫

復制代碼 代碼如下:
<a href="photo1.jpg" rel="external nofollow" onClick="return enlarge('photo1.jpg',event)"><img src="thumbnail.gif" border="0"></a>

 

記得更改圖片路徑

希望本文所述對大家Javascript程序設計有所幫助。


注:相關教程知識閱讀請移步到JavaScript/Ajax教程頻道。
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 杂多县| 永泰县| 桦南县| 昆明市| 金山区| 平顶山市| 纳雍县| 芷江| 含山县| 平邑县| 海安县| 尉氏县| 特克斯县| 乌兰浩特市| 岐山县| 武鸣县| 潞城市| 南部县| 南陵县| 兴仁县| 武定县| 南充市| 资源县| 西宁市| 醴陵市| 钟山县| 盐源县| 通渭县| 酒泉市| 巫山县| 清水县| 桐城市| 河东区| 德钦县| 宜都市| 登封市| 桐乡市| 封开县| 安宁市| 合水县| 绥滨县|