The text selected by textarea in Mozilla used createRange to determine the text selected by textarea. This attribute is supported by Mozilla, but it does not work if it is placed in textarea.
Later, we found that we could use other methods to solve the Mozilla problem.
<Head> <title> Textarea select </title> <meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8 "/> <meta name =" keywords "content =" php, mysql, wap, javacrept, 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 have not selected the text --! "); Return false} alert (sel. text)} else {// For Firefox var startPos = ta. selectionStart var endPos = ta. selectionEnd if (startPos = endPos) {alert ("You have not selected any text --! "); Return false} alert (ta. value. substring (startPos, endPos)} ta. focus ()} // --> script </pead> <body> <p> <input type = button onclick = "doS () "value =" show selected text "/> </p> <textarea id =" inTextarea "cols = 60 rows = 10> </textarea> </body> </ptml>
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]