您的位置:首页 > 其它

点击复制按钮进行复制文本

2016-04-06 15:03 225 查看
<script type="text/javascript">function jsCopy(){var e=document.getElementById("contents");//对象是contentse.select(); //选择对象 (全选)document.execCommand("Copy"); //执行浏览器复制命令}</script><textarea id="contents" cols="40" rows="5"></textarea><br /><input type="button" onClick="jsCopy();" value="复制" />相关代码:
//将当前页面另存为
document.execCommand(”SaveAs”);
//剪贴选中的文字到剪贴板;
document.execCommand(”Cut”,”
false
”,
null
);
//删除选中的文字;
document.execCommand(”Delete”,”
false
”,
null
);
//改变选中区域的字体;
document.execCommand(”FontName”,”
false
”,sFontName);
//改变选中区域的字体大小;
document.execCommand(”FontSize”,”
false
”,sSize|iSize);
//设置前景颜色;
document.execCommand(”ForeColor”,”
false
”,sColor);
//使绝对定位的对象可直接拖动;
document.execCommand(”2D-Position”,”
false
”,”
true
”);
//使对象定位变成绝对定位;
document.execCommand(”AbsolutePosition”,”
false
”,”
true
”);
//设置背景颜色;
document.execCommand(”BackColor”,”
false
”,sColor);
//使选中区域的文字加粗;
document.execCommand(”Bold”,”
false
”,
null
);
//复制选中的文字到剪贴板;
document.execCommand(”Copy”,”
false
”,
null
);
//设置指定锚点为书签;
document.execCommand(”CreateBookmark”,”
false
”,sAnchorName);
//将选中文本变成超连接,若第二个参数为true,会出现参数设置对话框;
document.execCommand(”CreateLink”,”
false
”,sLinkURL);
//设置当前块的标签名;
document.execCommand(”FormatBlock”,”
false
”,sTagName);
//相当于单击文件中的打开按钮
document.execCommand(”Open”);
//将当前页面另存为
document.execCommand(”SaveAs”);
//剪贴选中的文字到剪贴板;
document.execCommand(”Cut”,”
false
”,
null
);
//删除选中的文字;
document.execCommand(”Delete”,”
false
”,
null
);
//改变选中区域的字体;
document.execCommand(”FontName”,”
false
”,sFontName);
//改变选中区域的字体大小;
document.execCommand(”FontSize”,”
false
”,sSize|iSize);
//设置前景颜色;
document.execCommand(”ForeColor”,”
false
”,sColor);
//使绝对定位的对象可直接拖动;
document.execCommand(”2D-Position”,”
false
”,”
true
”);
//使对象定位变成绝对定位;
document.execCommand(”AbsolutePosition”,”
false
”,”
true
”);
//设置背景颜色;
document.execCommand(”BackColor”,”
false
”,sColor);
//使选中区域的文字加粗;
document.execCommand(”Bold”,”
false
”,
null
);
//复制选中的文字到剪贴板;
document.execCommand(”Copy”,”
false
”,
null
);
//设置指定锚点为书签;
document.execCommand(”CreateBookmark”,”
false
”,sAnchorName);
//将选中文本变成超连接,若第二个参数为true,会出现参数设置对话框;
document.execCommand(”CreateLink”,”
false
”,sLinkURL);
//设置当前块的标签名;
document.execCommand(”FormatBlock”,”
false
”,sTagName);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  复制到粘贴板