javascript 圖片上傳預(yù)覽-兼容標準
更新時間:2009年06月01日 01:51:21 作者:
js圖片上傳預(yù)覽
復(fù)制代碼 代碼如下:
<!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=gb2312" />
<title>js圖片上傳預(yù)覽</title>
<script language="javascript" type="text/javascript">
function $(obj){
return document.getElementById(obj);
}
window.onload = function(){
$("file1").onchange = function(){
this.select();
$("img1").src = "file:///"+document.selection.createRange().text;
}
}
</script>
</head>
<body>
<form name="form1">
<input type="file" name="file1" id="file1" />
</form>
<img src="#" id="img1" />
</body>
</html>
保存到本地.htm格式,即可
相關(guān)文章
JavaScript中Location.search處理使用方法
本文主要介紹了JavaScript中Location.search處理使用方法,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2023-04-04iframe窗口高度自適應(yīng)的又一個巧妙實現(xiàn)思路
這篇文章主要介紹了實現(xiàn)iframe窗口高度自適應(yīng)的又一個巧妙思路,需要的朋友可以參考下2014-04-04JavaScript 解析數(shù)學(xué)表達式的過程詳解
這篇文章主要介紹了JavaScript 解析數(shù)學(xué)表達式的過程詳解,本文以一個的解題思路,來分享如何解決問題,解決的過程,可以作為解決工作中一般問題的通用思路,對js解析表達式相關(guān)知識感興趣的朋友一起看看吧2022-06-06