<html>
<script>
function jcopy(o, msg)
{
var contents = o.value.toString();
if (contents=="") return false;
try
{
clipboardData.setData('Text',contents);
o.select();
alert(msg);
return false;
}
catch(e){alert("failed");return null;}
}
</script>
使用:
<input type="text" name="foo" id="foo" value="i am test" /> <input type="button" onclick="jcopy(document.getElementById('foo'),'拷貝成功,你可以發給好友了!')" value="點此拷貝" />
</html>
posted on 2007-09-25 11:56
lk 閱讀(149)
評論(0) 編輯 收藏 所屬分類:
ajax&js