<script type=”text/javascript”>

function CutToClipboard()

{

   CutTxt = document.selection.createRange();

   CutTxt.execCommand(”Cut”);

}

function CopyToClipboard()

{

   CopiedTxt = document.selection.createRange();

   CopiedTxt.execCommand(”Copy”);

}

function PasteFromClipboard()

{

   document.Form1.txtArea.focus();

   PastedText = document.Form1.txtArea.createTextRange();

   PastedText.execCommand(”Paste”);

}

</script>
 
And the markup:
 
 <form name=”Form1″>

Select this text, copy it using the copy button, and paste it below.<br /><br />

<textarea id=”txtArea” cols=”60″ rows=”5″></textarea>

<br />

<input type=”button” onClick=”CutToClipboard()” value=”Cut to clipboard” />

<input type=”button” onClick=”CopyToClipboard()” value=”Copy to clipboard” />

<input type=”button” onClick=”PasteFromClipboard()” value=”Paste from clipboard” />

</form>

====================================================

上面的Code有可能不能用,不能的話就試試看下面的

    <script type=”text/javascript”>

function CopyToClipboard()

{

   document.Form1.txtArea.focus();

   document.Form1.txtArea.select();

   CopiedTxt = document.selection.createRange();

   CopiedTxt.execCommand(”Copy”);

}

</script>

<textarea id=”txtArea” cols=”60″ rows=”5″>You can also copy text from this textarea. Or you can paste the text here, using the Ctrl+V key combination.</textarea>

<br />

<input type=”button” onClick=”CopyToClipboard()” value=”Copy to clipboard” />

文章標籤
全站熱搜
創作者介紹
創作者 包爾伯 的頭像
包爾伯

<font color="#FF0000">人生過程精彩才是重點</font>

包爾伯 發表在 痞客邦 留言(0) 人氣(3,782)