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;}'/>
"
;
}
查看全文
相关阅读:
switch 语句注意事项
line-height 和 font-size的关系
HTTP 缓存
hashchange事件的认识
面向对象的写法,见到就添,持续更新。。。
chrome浏览器开发者工具之同步修改至本地
history对象的一些知识点
你不知道的函数节流,提高你的JS性能!
玩媒体查询,就是这么简单粗暴!
css中clip-path属性的运用
原文地址:https://www.cnblogs.com/nasdaqhe/p/542008.html
最新文章
Cisco CCNP 学习笔记-BGP
CentOS7部署ToughRadius
bit、Byte、bps、Bps、pps、Gbps的单位详细说明及换算
C#之密封类(详解)
C#之调用存储过程
C#之实体类
分层开发之C#分层
大话设计模式之简单工厂
xml之基本操作
C#之单列双列集合绑定数据
热门文章
C#之九大视图
C#之考勤系统
C#之经理评分系统
JAVA:public static void main(String args[]) 详解
Java 提示“找不到或无法加载主类” 解决方法
JavaScript创建对象的7种模式
ES6:let 块作用域
HTML5 WebStorage(HTML5本地存储技术)
Cookie 机制
JavaScript 变量声明提升
Copyright © 2011-2022 走看看