js复制剪贴板

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>JS复制到剪切板</title>
</head>
<script>
function showDivLinkCopy() {
	var msg=document.getElementById("text").value;
    window.clipboardData.setData("Text",msg);	
}
</script>
<body>
<input name="" type="text" id="text" value="点击右边的复制"  style=" border:1px solid #ccc; padding:4px; font-size:14px; color:#444; width:200px; line-height:20px;" />
<a href="javascript:void(0);" onclick="showDivLinkCopy()" style="padding-left:15px; line-height:30px; font-size:16px;">复制</a>
</body>
</html>


 

你可能感兴趣的:(js复制剪贴板)