JS implementation picture paste to web page

This article implements the picture paste the picture on the paste board into the web page by pressing Ctrl + V, do not say direct code

         #img {width: 500px;}  JS implementation picture paste to web page插图 paste pictures by Ctrl + V    setPasteIMG () ; // get image function setPasteImg pasteboard () {// event paste document.addEventListener ( 'paste', function (event) {if (event.clipboardData || event.originalEvent) {var clipboardData = (event.clipboardData || Event.ORIGINALEVENT.CLIPBOARDDATA); if (clipboardData.items) {var blob; for (var i = 0; i < clipboardData.items.length; i++) {
       if (clipboardData.items[i].type.indexOf("image") !== -1) {
        blob = clipboardData.items[i].getAsFile();
      var render = new FileReader();
      render.onload = function (evt) {
       var base64 = evt.target.result;

The above is all the contents of this article, I hope to help everyone, I hope everyone supports Tumi Cloud. js实现图片粘贴到网页

© Copyright Notice
Just support it if you like
comment Grab the couch

Please log in to comment