Upload picture preview, support IE6, IE7, IE8, IE9, IE10, IE11. Firefox, Chrome is not specifically tested, but the high version is supported.
Imgpreviewqs.js
/*! Relies on JQuery 1.5.2 (c) 2016 license:http://www.opensource.org/licenses/mit-license.php/(function ($) {$.fn.imgprevie WQS = function (options) {function Isie (ver) {var b = document.createelement (' b ') b.innerhtml = ' <!--[if IE ' + ver + ']><i></i><!
[endif]--> ' return b.getelementsbytagname (' i '). length = = 1;
Options = $.extend ({}, $.fn.imgpreviewqs.defaults,options);
var $this =$ (this); $this. Change (function () {var regex=/(. *) \. (. *) \.
Jpg|jpeg|gif|bmp|png) $/;
var val = $this. val ();
if (!regex.test (val)) {Alert ("Please select Picture");
return false;
} if (Browserqs.isie (8)) {HanderIE789 ($this); else if (window.
FileReader) {handerfilereader ($this);
else if (Browserqs.isie (9)) {HanderIE789 ($this);
else if (Browserqs.isie (6)) {Handerother ($this);
else if (Browserqs.isie (7)) {HanderIE789 ($this); } else{$ ("#" +options.destid). HTML (Browser does not support previewing pictures));
}
}); function Handerfilereader ($this) {var opreviewimg = null, Ofreader = new window. FileReader (), Rfilter =/^ (?: Image\/bmp|image\/cis\-cod|image\/gif|image\/ief|image\/jpeg|image\/jpeg|image\/jpeg |image\/pipeg|image\/png|image\/svg\+xml|image\/tiff|image\/x\-cmu\-raster|image\/x\-cmx|image\/x\-icon|image\ /x\-portable\-anymap|image\/x\-portable\-bitmap|image\/x\-portable\-graymap|image\/x\-portable\-pixmap|image\/
X\-rgb|image\/x\-xbitmap|image\/x\-xpixmap|image\/x\-xwindowdump) $/i; Ofreader.onload = function (ofrevent) {$ ("#" +options.destid). HTML (" ");
};
var afiles = $this. Get (0). files;
if (Afiles.length = = 0) {return;}
if (!rfilter.test (Afiles[0].type)) {alert ("Please select Picture");
Ofreader.readasdataurl (Afiles[0]); The function HanderIE789 ($this) {$ ("#" +options.destid). CSS ("filter", "Progid:DXImageTransform.Microsoft.AlphaImageL OadER (sizingmethod=scale,src= ' "+geturl ($this) +" ') "; The function Handerother ($this) {$ ("#" +options.destid). HTML (" ");
function GetUrl ($this) {$this. Select ();
$this. blur ();
var imgsrc =document.selection.createrange (). text;
Document.selection.empty ();
return imgsrc;
}
}; $.fn.imgpreviewqs.defaults = {destid: ""})
(JQuery);