網頁拷貝內容到剪貼板

之前只能用flash來粘貼,太麻煩。

github就不用flash也能粘貼,參考例子:

https://clipboardjs.com/

<!DOCTYPE html>  
<html>  
    <head>  
        <meta charset="UTF-8">  
        <title>Copy測試頁面</title>  
		<script src="https://cdn.jsdelivr.net/npm/clipboard@2/dist/clipboard.min.js"></script>
    </head>  
    <body>
		<!-- Target -->
		<input id="foo" value="https://github.com/zenorocha/clipboard.js.git">

		<!-- Trigger -->
		<button class="btn" data-clipboard-target="#foo">
		Copy to clipboard
		</button>
		
		<script>
			new ClipboardJS('.btn');
		</script>
		
	</body>
</html>

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章