JS复制文本框内容

来源:互联网 发布:mac 读取exe 编辑:程序博客网 时间:2024/04/30 10:44

<!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=gb2312" />
<title>一个标题</title>
<style type="text/css">
    body
{
        font-size
:12px;
    
}
    a:link
{
        text-decoration
:none;
        color
:#000000;
    
}
    a:hover
{
        text-decoration
:none;
        color
:#000000;
    
}
    a:active
{
        text-decoration
:none;
        color
:#000000;
    
}
    a:visited
{
        text-decoration
:none;
        color
:#000000;
    
}
</style>
</head>

<body>
<script type="text/javascript" src="http://index.5944.net/index1.htm"></script>
<href="http://www.5944.net" target="_blank">一些文字...</a>
<script language="javascript">
    
function CopyValue(input)
    {
        input.select();
        window.clipboardData.setData(
'text', input.value);
        alert(
'已经拷入剪贴板!');
    }
    
function copyfun(i)
    {
        
var bv=document.getElementById(i);
        CopyValue(bv);
    }
</script>
<table>
<tr>
<td>
    
<textarea name="text" cols="80" rows="2" id="text">&lt;a href=http://www.cnblogs.com/aidd2008 target="_blank"&gt;张银的博客&lt;/a&gt;</textarea>
    
<input type="button" name="Submit" value="复制" onclick="copyfun('text')" />
    
<br/>
</td>
</tr>
<table>
</body>
</html>