霜巧
霜巧
文章目录
  1. JS execCommand方法 Demo

JS execCommand方法 Demo

JS execCommand方法 Demo


execCommand只有IE提供支持,查看Demo需在IE浏览器中打开

代码:

<style type="text/css">
textarea{
width:500px;
height:100px;
}
</style>
<script type="text/javascript">
<!--
function copy(){
document.execCommand("copy",false,null);
}
function selectAll(){
document.execCommand("selectAll",false,null);
}
function open(){
document.execCommand("open",false,null);
}
function saveAs(){
document.execCommand("saveAs",false,null);
}
function print(){
document.execCommand("print",false,null);
}
//->
</script>
<div>
<textarea cols="30" rows="10"></textarea>
</div>
<div>
<input type="button" value="copy" onClick="copy();" />
<input type="button" value="selectAll" onClick="selectAll();" />
<input type="button" value="open" onClick="open();" />
<input type="button" value="saveAs" onClick="saveAs();" />
<input type="button" value="print" onClick="print();" />
</div>

Demo