当前位置:网站首页>JS to paste pictures into web pages
JS to paste pictures into web pages
2022-06-23 01:30:00 【hhzzcc_】
Achieved by pressing ctrl + v Paste the picture on the pasteboard into the web page , Go straight to the code without saying anything
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> Picture paste </title>
<style> #img{ width: 500px; } </style>
<img id="img" src="" alt="">
adopt Ctrl + v Paste the picture
</head>
<body>
<script> setPasteImg(); // Get the picture on the pasteboard function setPasteImg(){ // Paste the event 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) { // Output base64 code var base64 = evt.target.result; document.getElementById('img').setAttribute('src',base64); } render.readAsDataURL(blob); } } }) } </script>
</body>
</html>Results,

边栏推荐
- [hdu] p2087 cut cloth strip
- SFOD:无源域适配升级优化,让检测模型更容易适应新数据
- Population standard deviation and sample standard deviation
- Steps to implement a container global component
- How to calculate the position of gold ETF
- [cmake command notes]find_ path
- Autumn move script C
- OSPF experiment in mGRE environment
- 总体标准差和样本标准差
- 62. different paths
猜你喜欢

基于深度学习的视觉目标检测技术综述

Local deployment and problem solving of IIS in ArcGIS JS 4.23

Debian10 LVM logical volumes

SFOD:无源域适配升级优化,让检测模型更容易适应新数据

A hundred lines of code to realize reliable delay queue based on redis

Charles garbled code problem solving

Autumn move script C

LeetCode 206. Reverse linked list (iteration + recursion)

SAP ui5 application development tutorial 102 - detailed trial version of print function implementation of SAP ui5 application

Debian10 configuring rsyslog+loganalyzer log server
随机推荐
Leetcode question brushing - 715 Range module
a++,++a,!,~
Add expiration time for localstorage
Get the start and end dates of the current week
層次選擇器
Local deployment and problem solving of IIS in ArcGIS JS 4.23
Debian10 installing zabbix5.4
The devil cold rice # 099 the devil said to travel to the West; The nature of the boss; Answer the midlife crisis again; Specialty selection
Error reported when compiling basalt
Shell view help
Up the Strip
Cadence spb17.4 - Chinese UI settings
Day260: the number III that appears only once
leetcode 91. Decode ways (medium)
C#. Net universal database access encapsulation classes (access, sqlserver, Oracle)
Template specialization template <>
Huawei cloud recruits partners in the field of industrial intelligence to provide strong support + commercial realization
Ansible learning summary (7) -- ansible state management related knowledge summary
[Title Fine brushing] 2023 Hesai FPGA
3DMAX modeling notes (I): introducing 3DMAX and creating the first model Hello World