new document
<script> <BR> String.prototype.trim = function() { <BR> return this.replace(/^\s+|\s+$/g, ""); <BR> } <BR> /* 方法一 FF下有点问题 */<BR> function getSelectText() { <BR> try{<BR> // IE: document.selection.createRange() W3C:window.getSelection()<BR> var selectText = (document.selection && document.selection.createRange )? document.selection.createRange().text : window.getSelection().toString();<BR> if(selectText != null && selectText.trim() != ""){<BR> return selectText;<BR> }<BR> }catch(err){}<BR> } <BR> /* 方法二 */<BR> function getSelectText2(id) {<BR> var t = document.getElementById(id);<BR> if(window.getSelection) {<BR> if(t.selectionStart != undefined && t.selectionEnd != undefined) {<BR> return t.value.substring(t.selectionStart, t.selectionEnd);<BR> } else {<BR> return "";<BR> }<BR> } else {<BR> return document.selection.createRange().text;<BR> }<BR> }<BR> document.getElementById('btn').onclick = function() {<BR> document.getElementById('show').innerHTML = getSelectText2('content');<BR> }<BR></script>