Created
May 13, 2014 06:42
-
-
Save cycold/0ef1454bbca93301d235 to your computer and use it in GitHub Desktop.
chrome浏览器支持从clipboard读取复制的数据 粘贴图片
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Convert image from clipboard to base64 encoded data with JavaScript | |
http://stackoverflow.com/questions/11194209/convert-image-from-clipboard-to-base64-encoded-data-with-javascript | |
<div contenteditable></div> | |
$('div[contenteditable]').bind('paste', function(e) { | |
alert(123); | |
var data = e.originalEvent.clipboardData.items[0].getAsFile(); | |
var elem = this; | |
var fr = new FileReader; | |
fr.onloadend = function() { | |
var img = new Image; | |
img.onload = function() { | |
$(elem).append(img); | |
}; | |
img.src = fr.result; | |
}; | |
fr.readAsDataURL(data); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment