当前位置:网站首页>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,

边栏推荐
- Flink synchronizes MySQL data to es
- JS to determine whether the browser has opened the console
- Learn the specific technical learning experience of designing reusable software from the three levels of class, API and framework
- Up the Strip
- What aspects of language and database knowledge are needed to build a web Kanban!
- Sfod: passive domain adaptation and upgrade optimization, making the detection model easier to adapt to new data
- Requête linq
- 3D printing microstructure
- JS to read the picture of the clipboard
- 基于深度学习的视觉目标检测技术综述
猜你喜欢

Autumn move script B

崔鹏团队:万字长文梳理「稳定学习」全景图

On AI and its future trend | community essay solicitation

Cadence spb17.4 - Chinese UI settings

SQL programming task02 job - basic query and sorting

Ros2 summer school 2022 transfer-

Charles garbled code problem solving

How about precious metal spot silver?

LeetCode 206. 反转链表(迭代+递归)

B tree and b+ tree
随机推荐
[luogu] p1083 [noip2012 improvement group] borrow classroom (line segment tree)
[UVM] don't say that your VIP can't use ral model
[cmake command notes]target_ compile_ options
[template] KMP
Vector 6 (inheritance)
Read Amazon memorydb database based on redis
C#.NET万能数据库访问封装类(ACCESS、SQLServer、Oracle)
Philosopher's walk gym divide and conquer + fractal
B tree and b+ tree
[Title Fine brushing] 2023 Hesai FPGA
Hierarchy selector
LeetCode 206. Reverse linked list (iteration + recursion)
Sfod: passive domain adaptation and upgrade optimization, making the detection model easier to adapt to new data
OSPF experiment in mGRE environment
Get the start and end dates of the current week
OSPF comprehensive experiment
Dual cross domain: access allow origin header contains multiple values "*, *", but only one is allowed
SYSTEMd summary
Data skew analysis of redis slice cluster
office2016+visio2016