The result is written out, before the time is not compatible with Firefox, then see a post upstairs a method, testing the compatibility is very good, on the reference;
The specific method I have organized into a file, you can preview the effect, you can also download the source directly browsing:
| The code is as follows |
Copy Code |
<! DOCTYPE html> <meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/> <meta name= "viewport" content= "Width=device-width, initial-scale=1.0" > <meta http-equiv= "x-ua-compatible" content= "Ie=edge" > <title>js get mouse-selected content </title> <body> <textarea id= "Text1" cols= "rows=" "5" >hello world!</textarea> <br> selection prompts for pop-up selection </body> <script> var Txt=document.getelementbyid ("Text1"); Txt.onselect=function (e) { Alert (Txt.value.slice (txt.selectionstart,txt.selectionend)); } </script> |