The jQuery plugin imgPreviewQs implements image preview and jqueryimgpreviewqs

Source: Internet
Author: User

The jQuery plugin imgPreviewQs implements image preview and jqueryimgpreviewqs

Preview uploaded images, including Internet Explorer 6, Internet Explorer 7, Internet Explorer 8, Internet Explorer 9, Internet Explorer 10, and Internet Explorer 11. Firefox and Chrome are not tested, but they are supported in later versions.

ImgPreviewQs. js

/*! Dependent on jQuery 1.5.2 (c) 2016 license: http://www.opensource.org/licenses/mit-license.php#/ (function ($) {$. fn. imgPreviewQs = 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 ("select image"); 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 {$ ("#" javasoptions.destid#.html ("preview images not supported by browsers ");}}); function HanderFileReader ($ this) {var oPreviewI Mg = null, oFReader = new window. FileReader (), rFilter =/^ (?: Image \/bmp | image \/cis \-cod | image \/gif | image \/ief | 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) {$ ("#" incluoptions.destid).html ("

Articles you may be interested in:
  • Jquery-based code for Image Upload and image size verification and image Preview
  • JQuery enables local preview and upload of images

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.