会员
周边
众包
新闻
博问
闪存
所有博客
当前博客
我的博客
我的园子
账号设置
简洁模式
...
退出登录
注册
登录
nasdaqhe's blog
被生活强jian着
博客园
::
首页
::
新随笔
::
联系
::
订阅
::
管理
公告
javascript实现图片预览
Posted on
2006-10-27 16:47
nasdaqhe
阅读(
386
) 评论(
0
)
编辑
收藏
举报
<
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;}'/>
"
;
}
会员力量,点亮园子希望
刷新页面
返回顶部
Powered by:
博客园
Copyright © 2024 nasdaqhe
Powered by .NET 8.0 on Kubernetes