ClipBoard
Copying text to the clipboard with javascript,high performance,no Flash, no dependece
Install / Use
/learn @milan-hwj/ClipBoardREADME
SuperClipBoard
Copying text to the clipboard with javascript,
high performance,no Flash, no dependece.
- Just 2KB
- Easy to get started, only two interface(bind and copy)
- <strong>High performance, copy speed: 3000KB/s</strong>
Getting started
Step 1:Install
npm install superClipBoard --save
<strong>You can also download the file directly. </strong>
Step 2:Import js file
<script type="text/javascript" src="../dist/superClipBoard.min.js"></script>
Step 3: Bind
<button id="btn" data-copy-content="Hello">copy 'Hello'</button>
<script>
// fast bind
superClipBoard.bind(document.getElementById('btn'));
</script>
Usage
Bind copy event
Set a 'data-copy-content' attribute in your trigger element
<div class="example1" data-copy-content="Hello World">copy</div>
then you can using a variety of selector to bind copy event.
// example1: document selector
superClipBoard.bind(document.getElementsByClassName('example1'));
// example2: selector like jquery
superClipBoard.bind('.example2');
// example3: jquery nodes (import jquery)
superClipBoard.bind($('.example3'));
// example4: simple dom array
superClipBoard.bind([
document.getElementById('example4_1'),
document.getElementById('example4_2')
]);
DIY copy event
// You can use any event such as click, mouseover, mouseover etc.. to bind copy behavior
// IE browser using 'attachEvent' binding event
document.getElementById('btn1').addEventListener("click", function(){
// use 'copy(content)' to set the copy content
// The copy function return result: boolean(ture or false)
superClipBoard.copy('Hello');
});
Copy feedback
Both 'copy' and 'bind' are provide feedback.
// copy feedback
var option = {
success: function(){
alert('copy success');
},
// If clipboad is not big enough to storage text, it will run this function
// The max size of clipboad depend on your runing envrionment
error: function(){
alert('copy error');
}
}
// bind Event
document.getElementById('btn1').addEventListener("click", function(){
superClipBoard.copy('Hello', option);
});
// fast bind
superClipBoard.bind(document.getElementById('btn2'), option);
License
Related Skills
node-connect
348.0kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
108.8kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
348.0kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
348.0kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
