当前位置:网站首页>js读取剪切板的图片
js读取剪切板的图片
2022-06-22 20:50:00 【紫微前端】
<script>
function test(evt){
//for chrome
var clipboardData = evt.clipboardData;
for(var i=0; i<clipboardData.items.length; i++){
var item = clipboardData.items[i];
if(item.kind=='file'&&item.type.match(/^image\//i)){
//blob就是剪贴板中的二进制图片数据
var blob = item.getAsFile(),reader = new FileReader();
//定义fileReader读取完数据后的回调
reader.onload=function(){
var sHtml='<img src="'+event.target.result+'">';//result应该是base64编码后的图片
document.getElementById('dd').innerHTML += sHtml;
}
reader.readAsDataURL(blob);//用fileReader读取二进制图片,完成后会调用上面定义的回调函数
}
}
}
</script>
<textarea id="t" onpaste="test(event)" cols=60 rows=5></textarea>
<div id="dd"></div>边栏推荐
- 别再用 System.currentTimeMillis() 统计耗时了,太 Low,StopWatch 好用到爆!
- LinkedList source code analysis
- What are the indicators, dimensions and models in Business Intelligence BI data warehouse?
- Mysql database DQL exercise
- Enabling partners, major guarantee of Spring Festival "non-stop"
- Mysql database design
- Greedy interval problem (1)
- A group of K overturned linked lists [disassembly / overturning / assembly of linked lists]
- SourceTree版本管理常用操作
- Adblock blocks Baidu hot search
猜你喜欢

ArcGIS application (20) the ArcGIS grid image symbol system prompts "this dataset does not have valid histogram required for classificati..."

2021-08-26

Summary of just meal with 900W increase in playback and acclaim from station B users

In the middle of the year, we will promote the integration of worry free, and the value-added package will be reduced by 6
Several ways of redis persistence -- deeply parsing RDB

安装typescript环境并开启VSCode自动监视编译ts文件为js文件

《强化学习周刊》第50期:SafeRL-Kit、GMI-DRL、RP-SDRL & 离线元强化学习
Task cache compilation caused by gradle build cache

2021-04-16

Huawei cloud recruits partners in the field of industrial intelligence to provide strong support + commercial realization
随机推荐
为 localStorage 添加过期时间
2021-08-21
Remote access and control - SSH Remote Management and TCP wrappers access control
Mysql database DQL query operation
Lua -- iterator, module, meta table
2021-03-06
MySQL constraints
Several methods of changing 91 Oracle common table into partitioned table
c# sqlsugar,hisql,freesql orm框架全方位性能测试对比 sqlserver 性能测试
Spark RDD Programming Guide(2.4.3)
In the third week of June, the main growth ranking list (BiliBili platform) of station B single feigua data up was released!
Delphi SOAP WebService 服务器端多个 SoapDataModule 要注意的问题
Plan and change of continuous repair
ArcGIS应用(二十)Arcgis 栅格图像符号系统提示“This dataset does not have valid histogram required for classificati…”
2021-05-02
2021-01-29
Generate detailed API and parameters of QR code using qrcodejs2
Spark SQL Start(2.4.3)
Solution to cache inconsistency
Is it bad for NFT that the market starts to cool down?