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

边栏推荐
- [ZOJ] P3228 Searching the String
- [cmake command notes]find_ path
- Population standard deviation and sample standard deviation
- Autumn move script a
- Installing MySQL for Linux
- LINQ 查詢
- C# SerializableDictionary序列化/反序列化
- Learn the specific technical learning experience of designing reusable software from the three levels of class, API and framework
- Vscade personalization: let a cute girl knock the code with you
- A blog allows you to understand the use of material design
猜你喜欢

Wallys/DR7915-wifi6-MT7915-MT7975-2T2R-support-OpenWRT-802.11AX-supporting-MiniPCIe

SAP mm transaction code vl04 create outbound delivery for sto

Read Amazon memorydb database based on redis

office2016+visio2016

Local deployment and problem solving of IIS in ArcGIS JS 4.23

How to calculate the position of gold ETF

SQL programming task05 job -sql advanced processing
![[machine learning watermelon book] update challenge [Day1]: 1.1 INTRODUCTION](/img/f6/b0df192502a59a32d8bac8c0862d02.png)
[machine learning watermelon book] update challenge [Day1]: 1.1 INTRODUCTION

Ros2 summer school 2022 transfer-

Psychological analysis of the safest spot Silver
随机推荐
SAP mm transaction code vl04 create outbound delivery for sto
Sfod: passive domain adaptation and upgrade optimization, making the detection model easier to adapt to new data
層次選擇器
Ansible learning summary (7) -- ansible state management related knowledge summary
Phantomjs Usage Summary
Vector 2 (friend and copy construction)
Ros2 summer school 2022 transfer-
Steps to implement a container global component
Day500: keyboard line
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
Found several packages [runtime, main] in ‘/usr/local/Cellar/go/1.18/libexec/src/runtime;
Unit of RMB in words
Up the Strip
Const defined variables and for of and for in in JS
SQL programming task03 job - more complex query
office2016+visio2016
[hdu] P6964 I love counting
You can also do NLP (classification)
Installing MySQL for Linux
魔王冷饭||#099 魔王说西游;老板的本质;再答中年危机;专业选择