var context = document.getElementById("文本区域id").value;
document.write(context);

解决方案 »

  1.   


    var oRange = document.selection.createRange(); // 取所选区域, oRange.text就是所选文字
    var sRangeType = document.selection.type;
    if(sRangeType == "Text"){
        oRange.pasteHTML("<b>" + oRange.text + "</b>");
    }
      

  2.   

    <SCRIPT LANGUAGE=javascript>
    <!--
    function alertselection(){
        alert(document.selection.createRange().text)
    }
    //-->
    </SCRIPT><INPUT id=text1 
    size=100 value="得到文本框选中的文字:自己用鼠标选中几个文字,然后就输出这几个文字,其他文字不输出来" onmouseup=alertselection()>
      

  3.   

    document.selection就是你用鼠标选中几个文字
    你到dhtml手册里面查就知道了