如何在FIREFOX下实现copy and paste(一百分赠送啊) 楼主实在是有分无处送。稍微 Google 一下就出来了。http://blog.csdn.net/hbcui1984/archive/2006/09/23/1269737.aspx 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我说的是在所见即所得的HTML编辑器里用javascript如何实现 没明白啥意思...在编辑框中直接ctrl+c或者鼠标右键不就粘贴了,你要提供的是啥功能? 是这个意思吗?<textarea id="editor" cols="50" rows="5" onfocus="getPostion()" onmouseup="getPostion()">实现在FIREFOX下利用脚本进行复制和粘贴,本脚本只适用于FIREFOX,如要兼容IE,请利用createTextRange()方法!</textarea><br><input type="button" id="bt_copy" value="复制" onclick="copy()"/><input type="button" id="bt_paste" value="粘贴" onclick="paste()"><script language="JavaScript"><!--var temp=""; //保存复制的字符var insert=0; //粘贴的位置var start=end=0; //选择的起止位置var textBox=btCopy=btPaste=null;window.onload=function(){ textBox = document.getElementById("editor"); btCopy=document.getElementById("bt_copy"); btPaste=document.getElementById("bt_paste"); btPaste.disabled=true;}function copy(){ //复制 start = textBox.selectionStart; end = textBox.selectionEnd; if(start==end) { alert("请选择复制的文字!"); return; } btPaste.disabled=false; temp = textBox.value.substring(start,end);}function paste(){ //粘贴 textBox.value = textBox.value.substr(0, insert) + temp + textBox.value.substr(insert);}function getPostion() //获取插入位置{ insert=textBox.selectionStart;}//--></script> http://codebit.cn/pub/html/javascript/tip/get_selection/兼容性确实麻烦,楼上的在IE下又不行了。 http://blog.csdn.net/hbcui1984/archive/2006/09/23/1269737.aspx javascript到底使用全局变量还是局部变量? Ext Grid 行 高度 问题 请问如何获得网页的scrollbar的x和y的移动距离啊 帮忙看下xmlhttp.Open方法错在哪了? 菜鸟求一个popup的样式 怎样同时打印一个页面以及这个页面中iframe中的内容 about Div in HTML and PHP 如何让弹出菜单显示在主页最上层 求记数作弊代码,原高分相赠. 怎样改变表单内容?在线等!! 请教下 Javascript 代码这样放置可以吗? 发个惠谱的Banner特效
<br>
<input type="button" id="bt_copy" value="复制" onclick="copy()"/><input type="button" id="bt_paste" value="粘贴" onclick="paste()">
<script language="JavaScript">
<!--
var temp=""; //保存复制的字符
var insert=0; //粘贴的位置
var start=end=0; //选择的起止位置
var textBox=btCopy=btPaste=null;window.onload=function(){
textBox = document.getElementById("editor");
btCopy=document.getElementById("bt_copy");
btPaste=document.getElementById("bt_paste");
btPaste.disabled=true;
}function copy(){ //复制
start = textBox.selectionStart;
end = textBox.selectionEnd;
if(start==end)
{
alert("请选择复制的文字!");
return;
}
btPaste.disabled=false;
temp = textBox.value.substring(start,end);
}function paste(){ //粘贴
textBox.value = textBox.value.substr(0, insert) + temp + textBox.value.substr(insert);
}function getPostion() //获取插入位置
{
insert=textBox.selectionStart;
}
//-->
</script>
兼容性确实麻烦,
楼上的在IE下又不行了。