该文档说了怎么在页面做图片预览, 一步一步的
//滤镜显示
_filterShow: function() {
this._filterPreload();
var preload = this._preload,
data = this._data.replace(/[)'"%]/g, function(s){ return escape(escape(s)); }); try{
preload.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = data; }catch(e){ this._error("filter error"); return; }
//设置滤镜并显示
this.img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod='scale',src=\"" + data + "\")";
this._imgShow( ImagePreview.TRANSPARENT, preload.offsetWidth, preload.offsetHeight ); },
//显示预览
_imgShow: function(src, width, height) {
var img = this.img, style = img.style,
ratio = Math.max( 0, this.ratio ) || Math.min( 1,
Math.max( 0, this.maxWidth ) / width || 1,
Math.max( 0, this.maxHeight ) / height || 1
);
//设置预览尺寸
style.width = Math.round( width * ratio ) + "px";
style.height = Math.round( height * ratio ) + "px";
//设置src
img.src = src;
this.onShow();
},
//销毁程序
dispose: function() {
//销毁上传文件对象
if ( this._upload ) {
this._upload.dispose(); this._upload = null;
}
//销毁预载图片对象
if ( this._preload ) {
var preload = this._preload, parent = preload.parentNode;
this._preload = preload.onload = preload.onerror = null;
parent && parent.removeChild(preload);
}
//销毁相关对象
this.file = this.img = null;