[問題] 關於execCommand('Copy')複製兩個textꨠ…
各位先進大家好~~
小弟我想做一個網頁
它有兩個text文字框和一個按鈕
當按下按鈕時
剪貼簿會複製兩個文字框字串的相加
例如:
text1='hello'
text2='world'
當按下按鈕時
剪貼簿就會存入'helloworld'
我想了好久
只能想到用以下的方法寫:
<form name="f2c">
<input name="text1" id="text1" type="text" value="">
<input name="text2" id="text2" type="text" value="">
<input type="button" value="複製到剪貼簿" onclick="copytext()">
<input name="text0" id="text0" type="text" value="">
</form>
<SCRIPT TYPE="text/javascript">
function copytext(){
document.f2c.text0.value=document.f2c.text1.value+document.f2c.text2.value;
f2c.text0.select();
document.execCommand('Copy');
}
</SCRIPT>
也就是說我又加了一個text0來存這兩個文字框的內容
這樣做起來很不美觀
請問有沒有不使用text0更快速的寫法呢?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 59.104.10.198
→
08/22 11:31, , 1F
08/22 11:31, 1F
→
08/22 12:04, , 2F
08/22 12:04, 2F
→
08/22 12:27, , 3F
08/22 12:27, 3F
→
08/22 12:48, , 4F
08/22 12:48, 4F
推
08/22 13:55, , 5F
08/22 13:55, 5F
謝謝,我發現解決的方法了,還是一樣用text0來存放,把它設為隱藏。
然後把copytext()的最後兩行改為:
clipboardData.setData ("Text",document.f2c.text0.value)
就可以了~~~
※ 編輯: jimsuan 來自: 59.104.10.198 (08/22 14:11)
→
08/22 14:13, , 6F
08/22 14:13, 6F
→
08/22 14:14, , 7F
08/22 14:14, 7F
→
08/22 14:17, , 8F
08/22 14:17, 8F
→
08/22 14:18, , 9F
08/22 14:18, 9F
ps..ff我目前是用_clipboard.swf這支flash去做剪貼簿的存取的
※ 編輯: jimsuan 來自: 59.104.10.198 (08/22 14:26)
→
08/22 14:34, , 10F
08/22 14:34, 10F