Home  >  Article  >  Web Front-end  >  javascript预览上传图片发现的问题的解决方法_图象特效

javascript预览上传图片发现的问题的解决方法_图象特效

WBOY
WBOYOriginal
2016-05-16 18:15:211296browse

先看看效果图吧:
javascript预览上传图片发现的问题的解决方法_图象特效
机会难得,有点技术亮点,就一下子投入到功能开发中去了。在这一块的功能开发中,自己还是学到些不错的东西,其中一点就是,用户选择上传的图片,如何预览出来呢。网上找了些资料,最终采用如下方法:

复制代码 代码如下:

function (obj) { //logo上传添加事件
var logoimg = null;
if (document.all) {//如果是IE情况下
obj.select();
logoimg = document.selection.createRange().text;
//由于是采用滤镜的方式,所以要把图片设置为不可见,在图片外层的DIV上面设置滤镜效果
$(".setup_logo_left img").removeAttr("src");
$(".setup_logo_left img").css("display", "none");
var img = document.getElementById("preview_fake");
img.filters.item(
'DXImageTransform.Microsoft.AlphaImageLoader').src = logoimg;
return;
}
logoimg = obj.files[0].getAsDataURL();
$(".setup_logo_left img").attr("src", logoimg);
}

效果很不错,在IE6,IE7,IE8,FOX,哦还有一个特让人纠结的360都正常显示
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn