<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” />
留言列表