Used to use Createrange to judge textarea selected text, this property although Mozilla also support, but put to textarea will not work.
It was later found that there were other ways to solve the Mozilla problem.
<pead> <title>textarea select</title> <meta http-equiv= "Content-type" content=; Charset=utf-8 "/> <meta name= keywords" content= "php,mysql,wap,javacript,xhtml,xml,wml,svg,,, mobile"/> ; script type= "Text/javascript" > <!--function DoS () {var Ta=document.getelementbyid ("Intextarea") if (document.selection) {//for IE var sel = Document.selection.createRange (); if (sel.text.length<1) {alert ("You do not select text--!"); return false} alert (Sel.text)} else{//for Firefox var startpos = Ta.selectionstart var endpos = Ta.selectionend if (startpos = = endpos) {alert ("You did not select text--!"); return false} alert (Ta.value.substring (Startpos,endpos))} ta.focus ()}//--> </script> </pead> <body> <div><input type=button onclick= "DoS ()" value= "Display selected text"/>< /div> <textarea id= "IntextaRea "cols=60 rows=10></textarea> </body> </ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]