日期:2014-05-16 浏览次数:20473 次
text: <input type="text" name="text" value="copy ok!" id="text"/>
<input type="submit" name="btn_copy" value="复制" id="btn_submit" />
<script type="text/javascript" src="ZeroClipboard.js"></script>
<script type="text/javascript">
var clip = new ZeroClipboard.Client();
clip.setHandCursor(true);
var text= document.getElementById("text").value;
clip.setText(text);
clip.glue("btn_submit");
clip.addEventListener( "complete", function(){
alert("复制成功!");
});
</script>
text: <input type="text" name="text" value="copy ok!" id="text"/>
<input type="submit" name="btn_copy" value="复制" id="btn_submit" onclick="copyToClipboard('text')" />
<script type="text/javascript" src="ZeroClipboard.js"></script>
<script type="text/javascript">
function copyToClipboard(txt){
var clip = new ZeroClipboard.Client();
clip.setHandCursor(true);
var text= document.getElementById(txt).value;
clip.setText(text);
clip.glue("btn_submit");
clip.addEventListener( "complete", function(){
alert("复制成功!");
});
}
</script>