马牛不是人

学姐说:“学习学习不后退”

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
点击文本框区域,使文本框中的文字被复制到剪切板。
<!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>
</head>

<body>
<script>
function copycode(obj){
obj.select();
objcopy
=obj.createTextRange();
objcopy.execCommand(
"Copy");
}
function trans(){
    
var str = "";
    rtf.focus();
    rtf.document.body.innerHTML 
= "";
    rtf.document.execCommand(
"paste");
    str 
= rtf.document.body.innerHTML;
    
if(str.length == 0) {
        alert(
"剪切版不存在超文本数据!");
        
return "";
    }
    
return html_trans(str);
}

</script>
<label>
<textarea name="textarea" cols="100" onbeforepaste="if(document.getElementById('x_paste').checked){window.clipboardData.setData('text',trans());this.focus();}" onclick="copycode(this)"></textarea>
</label>
<label></label>
<p>&nbsp;</p>
</body>
</html>
posted on 2006-04-30 17:00  马牛  阅读(221)  评论(0编辑  收藏  举报