等价的写法 方法一:提交 方法二:提交 __________________________________________________________________________ var t=((window.getSelection&&window.getSelection())||(document.getSelection&&document.getSelection())||(document.selection &&document.selection.createRange&&document.selection.createRange().text)); var e=(document.charset||document.characterSet); alert('页面选择的字符是:'+t); alert('页面的字符编码是:'+t); __________________________________________________________________________ document.selection.type 返回三个值 "None" "Text" "Control" 只有当返回值是 Text 时,创建的textRange才是有效的。