ie7下显示用户上传本地图片的解决办法
<html>
<head id="Head1" runat="server">
<title>Untitled Page</title>
<script language=javascript>
function setImagePreview( fileUrl )
{
var objDivFilter = document.getElementById("divFilter")
if( fileUrl )
{
objDivFilter.style.width = "400px";
objDivFilter.style.height = "400px"; //这个设置初始大小是必须的
objDivFilter.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod = image)";
objDivFilter.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = fileUrl;
// get width and height
alert( objDivFilter.offsetWidth)
alert( objDivFilter.offsetHeight)
}
}
</script>
<style>
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:FileUpload ID="txtFile" runat="server" Width="508px" onchange="javascript:setImagePreview( this.value );" />
<br />
<div id="divFilter" />
</div>
</form>
</body>