html数据复制到剪切板
生活随笔
收集整理的這篇文章主要介紹了
html数据复制到剪切板
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
一、原生js指令復制
function copyUtil(info) {var $textArea = $('<textarea></textarea>');$textArea.val(info);$textArea.css('opacity','0');$('body').append($textArea);$textArea.select();//通過執行copy指令將選中的信息復制到剪切板var status = document.execCommand('copy', false, null);$textArea.remove();//瀏覽器不支持copy指令if(!status) {status = prompt('請復制到剪切板', info);}return status; }$('#bt').click(()=>{ copyUtil('復制數據')});?
二、jquery.zclip的flash復制
引入插件
<script src="/zclip/jquery.zclip.js"></script>復制代碼?
$('#bt').zclip({path: "swf/ZeroClipboard.swf",copy: function(){//復制內容return "要復制的信息";},afterCopy: function(){//復制成功//復制后的操作do something} });?
創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的html数据复制到剪切板的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 智谱 AI 宣布完成超 25 亿元融资,
- 下一篇: 美光推出基于1β技术的DDR5内存 速率