JS实现复制,问题解决立即给分
JS实现复制
------解决方案--------------------window.clipboardData.setData( 'text ',str);
测试一下:
<script language= "javascript ">
function readTxt()
{
alert(window.clipboardData.getData( "text "));
}
function setTxt()
{
var t=document.getElementById( "txt ");
t.select();
window.clipboardData.setData( 'text ',t.createTextRange().text);
}
</script>
<input name= "txt " value= "测试 ">
<input type= "button " value= "复制 " onclick= "setTxt() ">
<input type= "button " value= "读取 " onclick= "readTxt() ">
------解决方案--------------------window.clipboardData.setData( 'text ',str);
测试一下:
<script language= "javascript ">
function readTxt()
{
alert(window.clipboardData.getData( "text "));
}
function setTxt()
{
var t=document.getElementById( "txt ");
t.select();
window.clipboardData.setData( 'text ',t.createTextRange().text);
}
</script>
<input name= "txt " value= "测试 ">
<input type= "button " value= "复制 " onclick= "setTxt() ">
<input type= "button " value= "读取 " onclick= "readTxt() ">
------解决方案--------------------我要分
------解决方案--------------------function CopyJs()
{
var jsArea =document.getElementById( "ctl00_Content_txtJSURL ");
if(jsArea.value != " ")
{
jsArea.focus();
jsArea.select();
document.execCommand( "copy ");
alert( "复制成功 ");
}
else
{
alert( "复制内容为空,请先升成调用JS! ");
}
}