国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 长垣县| 三原县| 永和县| 光山县| 绥德县| 金溪县| 黑河市| 天门市| 正镶白旗| 汉阴县| 交口县| 密云县| 琼结县| 深圳市| 元谋县| 宣威市| 南召县| 南汇区| 中卫市| 瓦房店市| 龙山县| 仙游县| 西林县| 贺兰县| 西丰县| 中山市| 西充县| 唐海县| 新邵县| 桐柏县| 五大连池市| 合水县| 会宁县| 沿河| 高青县| 雅江县| 河西区| 伊金霍洛旗| 连州市| 龙陵县| 刚察县|