zoukankan
html css js c++ java
javascript实现图片预览
<
input name
=
"
w_s
"
type
=
"
file
"
id
=
"
w_s
"
onChange
=
"
load_img(this.value,img_s);
"
>
<
input name
=
"
w_b
"
type
=
"
file
"
id
=
"
w_b
"
onChange
=
"
load_img(this.value,img_b);
"
>
<
div id
=
"
img_s
"
></
div
>
<
div id
=
"
img_b
"
></
div
>
<
script language
=
"
javascript
"
>
<!--
function
load_img(p_src,write_id)
{
var
t_html;
if
(p_src
!=
'')
{
if
(write_id
==
img_s)
{
t_html
=
"
<img src='
"
+
p_src
+
"
' onLoad='javascript:if(this.width>120){this.width=120;}if(this.height>120){this.height=120;}'>
"
;
}
else
{
t_html
=
"
<img src='
"
+
p_src
+
"
' onLoad='javascript:if(this.width>240){this.width=240;}if(this.height>240){this.height=240;}'>
"
;
}
}
else
{
t_html
=
""
;
}
write_id.innerHTML
=
t_html;
}
//
-->
function
change()
{
if
(form1.fType.value
==
0
)
{
labeltxt.innerText
=
"
图片预览:
"
;
showtxt.style.display
=
"
none
"
;
showpic.style.display
=
"
block
"
;
}
else
{
labeltxt.innerText
=
"
文字(txt):
"
;
showpic.style.display
=
"
none
"
;
showtxt.style.display
=
"
block
"
;
}
}
function
show()
{
showpic.innerHTML
=
"
<img src='
"
+
form1.file.value
+
"
' onLoad='javascript:if(this.width>256){this.height=this.height/(this.width/256);this.width=256;}if(this.height>256){this.width=this.width/(this.height/256);this.height=256;}'/>
"
;
}
查看全文
相关阅读:
Java数组的内存结构
2014.11.9--最近的小感悟
十一两天感悟
Are you happiness
Are you busy?
Lesson 81-82 Are they true
Lesson 79-80 People are getting sick
Lesson 77-78 Socially Discriminated Against
Lesson 75-76 Shopping on the web
更新单点,求区间—— luogu 3374
原文地址:https://www.cnblogs.com/nasdaqhe/p/542008.html
最新文章
DIV+CSS专题:十天学会DIV+CSS
css
第八章 jQuery与Ajax应用
第七章 jQuery操作表格及其它应用
第六章 jQuery操作表单
第五章 jQuery中的动画
第四章 jQuery中的事件
第三章 jQuery中的DOM操作
第二章 jQuery选择器
Are Landing Pages Killing Your Conversion Rate?
热门文章
2015互联网报告
农村的“无为教育” (FW)
创投女王徐新:如何迅速做到细分市场第一(FW)
家业兴衰说传承(cc)
table extraction
数字营销行业 2015年趋势预测总结
风口调研
摘要
韩衍隽:通向科研之巅的平凡之路
Java一维数组
Copyright © 2011-2022 走看看