楼主实在是有分无处送。稍微 Google 一下就出来了。
http://blog.csdn.net/hbcui1984/archive/2006/09/23/1269737.aspx

解决方案 »

  1.   

    我说的是在所见即所得的HTML编辑器里用javascript如何实现
      

  2.   

    没明白啥意思...在编辑框中直接ctrl+c或者鼠标右键不就粘贴了,你要提供的是啥功能?
      

  3.   

    是这个意思吗?<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>
      

  4.   

    http://codebit.cn/pub/html/javascript/tip/get_selection/
    兼容性确实麻烦,
    楼上的在IE下又不行了。
      

  5.   

    http://blog.csdn.net/hbcui1984/archive/2006/09/23/1269737.aspx