js:s上次預覽,上傳圖片預覽,圖片上傳預覽

來源:互聯網
上載者:User

標籤:大小   屬性   ntb   擷取   修改   glin   splay   logs   try   

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>By:DragonDean</title><script type="text/javascript">//下面用於圖片上傳預覽功能function setImagePreview(avalue) {var docObj=document.getElementById("doc"); var imgObjPreview=document.getElementById("preview");if(docObj.files &&docObj.files[0]){//Firefox下,直接設img屬性imgObjPreview.style.display = ‘block‘;imgObjPreview.style.width = ‘150px‘;imgObjPreview.style.height = ‘180px‘; //imgObjPreview.src = docObj.files[0].getAsDataURL(); //Firefox7以上版本不能用上面的getAsDataURL()方式擷取,需要一下方式imgObjPreview.src = window.URL.createObjectURL(docObj.files[0]);}else{//IE下,使用濾鏡docObj.select();var imgSrc = document.selection.createRange().text;var localImagId = document.getElementById("localImag");//必須設定初始大小localImagId.style.width = "150px";localImagId.style.height = "180px";//圖片異常的捕捉,防止使用者修改尾碼來偽造圖片try{localImagId.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale)";localImagId.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = imgSrc;}catch(e){alert("您上傳的圖片格式不正確,請重新選擇!");return false;}imgObjPreview.style.display = ‘none‘;document.selection.empty();}return true;} </script></head> <body><table width="100%" border="0" cellspacing="0" cellpadding="0"><tbody><tr><td height="101" align="center"><div id="localImag"><img id="preview" src="http://blog.chuangling.net/Public/images/top.jpg" width="150" height="180" style="display: block; width: 150px; height: 180px;"></div></td></tr><tr><td align="center" style="padding-top:10px;"><input type="file" name="file" id="doc" style="width:150px;" onchange="javascript:setImagePreview();"></td></tr></tbody></table></body></html>

  

js:s上次預覽,上傳圖片預覽,圖片上傳預覽

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.