因为安全性问题,IE7禁用了image控件引用本地图片,为了这个问题郁闷了好几天,终于找到了解决方案,好东西要与大家分享,代码如下:
此段代码放于<head> ....</head>之间
<
style type
=
"
text/css
"
>
#newPreview
{
FILTER: progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale)
}
</ style >
FILTER: progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale)
}
</ style >
<body>内的代码
<
script language
=
"
javascript
"
type
=
"
text/javascript
"
>
function PreviewImg(imgFile)
{
var newPreview = document.getElementById("newPreview");
newPreview.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = imgFile.value;
newPreview.style.width = "80px";
newPreview.style.height = "60px";
}
</ script >
< asp:FileUpload ID = " Fud_Pic " runat = " server " onchange = " PreviewImg(this) " />
< div id = " newPreview " ></ div >
function PreviewImg(imgFile)
{
var newPreview = document.getElementById("newPreview");
newPreview.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = imgFile.value;
newPreview.style.width = "80px";
newPreview.style.height = "60px";
}
</ script >
< asp:FileUpload ID = " Fud_Pic " runat = " server " onchange = " PreviewImg(this) " />
< div id = " newPreview " ></ div >
转自:http://www.cnblogs.com/RobotTech/archive/2007/09/14/893001.html
本人评:搜索很久了,都是长长的javascript代码之类。这个简单又好用!上传前可以预览,上传之后就没了