<
html
>
< head >
< title > Javascript 复制 Input 中内容到剪贴板 </ title/ >
< script language ="javascript" >
function copyToClipboard(theField,isalert)
{
var obj = document.getElementById(theField);
if (obj != null )
{
var clipBoardContent = obj.value;
obj.select();
window.clipboardData.setData( " Text " ,clipBoardContent);
if (isalert != false )
alert( " 复制成功。现在您可以粘贴(Ctrl+v)到QQ群中了。 " );
}
else
{
alert( " Error! " );
}
}
</ script >
</ head >
< body >
< span > 博客地址: </ span >
< input type ="text" id ="link" style ="width:215px;" value ="http://www.cnblogs.com/Anjou" />
< button onclick ="javascript:copyToClipboard('link',true);" > 复制 </ button >
</ body >
</ html >
< head >
< title > Javascript 复制 Input 中内容到剪贴板 </ title/ >
< script language ="javascript" >
function copyToClipboard(theField,isalert)
{
var obj = document.getElementById(theField);
if (obj != null )
{
var clipBoardContent = obj.value;
obj.select();
window.clipboardData.setData( " Text " ,clipBoardContent);
if (isalert != false )
alert( " 复制成功。现在您可以粘贴(Ctrl+v)到QQ群中了。 " );
}
else
{
alert( " Error! " );
}
}
</ script >
</ head >
< body >
< span > 博客地址: </ span >
< input type ="text" id ="link" style ="width:215px;" value ="http://www.cnblogs.com/Anjou" />
< button onclick ="javascript:copyToClipboard('link',true);" > 复制 </ button >
</ body >
</ html >