document.getElementById( 'testInput' ).addEventListener( 'paste', function( e ){
var clipboardData = e.clipboardData,
i = 0,
items, item, types;
if( clipboardData ){
items = clipboardData.items;
if( !items ){
return;
}
item = items[0];
types = clipboardData.types || [];
for( ; i < types.length; i++ ){
if( types[i] === 'Files' ){
item = items[i];
break;
}
}
if( item && item.kind === 'file' && item.type.match(/^image\//i) ){
imgReader( item );
}
}
});
})();
</script>
</body>
</html>
您可能感兴趣的文章: