前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >文本选择window.getSelection

文本选择window.getSelection

作者头像
马克java社区
修改2021-01-13 10:06:52
8150
修改2021-01-13 10:06:52
举报
文章被收录于专栏:java大数据java大数据

8.文本选择window.getSelection 例 1.8(文本选择IEFF.html) <html> <head>     <meta http-equiv="content-type" content="text/html; charset=utf-8"/>     <script type="text/javascript">        function fun1(){ if(window.getSelection){//DOM,FF,Webkit,Chrome,IE10 alert("马克-to-win:火狐click事件包括鼠标点下和抬起两个动作,不抬起不算结束,所以可以选择文本。 window.getSelection is "+window.getSelection); selectionText = window.getSelection(); }else if(document.getSelection){//IE10 selectionText = document.getSelection(); }else if(document.selection){//IE6+10- selectionText = document.selection.createRange().text; }else{ selectionText = ""; }            strlen = selectionText.toString();            alert(strlen);   //  alert(document.selection.createRange().text);        }    </script> <body> <body οnclick="fun1();"> <p>Select this textsfsadfsdafsdagfsadgsagsadgfsd</p> sdgsagsadgsafghgfhfh gsadgsaghfghfhgfhf sabhhfghgfhfghfh gsfdghf sdaggfhf gdhfghdf sdagdhg </body> </body> </html>

更多请见:https://blog.csdn.net/qq_44594371/article/details/103063544

本文系转载,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文系转载前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档