没用过这东西,查了半天手册...function   showSelection(){ 
var o = document.forms[0].selectedText, r;

if (window.getSelection) {
o.value = o.value.substring(o.selectionStart, o.selectionEnd);
} else {
o.value = document.selection.createRange().text;
}
window.setTimeout(function () {
o.focus();
o.select();
}, 0);

document.onmouseup = showSelection;

解决方案 »

  1.   

    document.getSelection和document.captureEvents(Event.MOUSEUP)是firefox的事件吧,在IE上测试。
      

  2.   

    document.captureEvents
    貌似已经废弃了...
      

  3.   

    function   showSelection(){
    if(document.getSelection)
      document.forms[0].selectedText.value=document.getSelection() ;
    else 
      document.forms[0].selectedText.value=document.selection.createRange().text 

    //document.captureEvents(event.mouseUp) 
    document.onmouseup=showSelection ;
      

  4.   

    谢谢各位!!
    document.selection.createRange().text 是啥子意思呢?
      

  5.   

    下面上ie的,ff的textrange的应用不是很了解.只知道一些简单的
    TextRange对象是动态HTML(DHTML)的高级特性,使用它可以实现很多和文本有关的任务,例如搜索和选择文本。文本范围让您可以选择性的将字符、单词和句子从文档中挑选出来。TextRange对象是在HTML文档将要显示的文本流上建立开始和结束位置的抽象对象。下面是TextRange的常用属性与方法:属性 
    boundingHeight 获取绑定TextRange对象的矩形的高度 
    boundingLeft 获取绑定TextRange 对象的矩形左边缘和包含TextRange对象的左侧之间的距离 
    offsetLeft 获取对象相对于版面或由offsetParent属性指定的父坐标的计算左侧位置 
    offsetTop 获取对象相对于版面或由offsetParent属性指定的父坐标的计算顶端位置 
    htmlText 获取绑定TextRange对象的矩形的宽度 
    text 设置或获取范围内包含的文本 
    方法 
    moveStart 更改范围的开始位置 
    moveEnd 更改范围的结束位置 
    collapse 将插入点移动到当前范围的开始或结尾 
    move 折叠给定文本范围并将空范围移动给定单元数 
    execCommand 在当前文档、当前选中区或给定范围上执行命令 
    select 将当前选择区置为当前对象 
    findText 在文本中搜索文本并将范围的开始和结束点设置为包围搜索字符串。