如何在web编辑器里面插入文本并选中状态 我想做编辑器里面插入 一段文本 并使这段文本属于选中状态怎么做document.execCommand 里面有这个方法吗?? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 《!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"》《html xmlns="http://www.w3.org/1999/xhtml"》《head》《meta content="text/html; charset=GBK" http-equiv="Content-Type" /》《title》无标题 1《/title》《/head》《body》《div style=" font-size:20px"》我需要在页面中增加一个js代码,当用户用鼠标选择文字(鼠标拖动涂蓝文字)时,会出现一个层,提示与这个选择文字有个的信息《/div》《br/》《br/》《br/》《br/》《br/》《br/》《br/》《br/》《br/》《div id="show"》《/div》《/body》《script type="text/javascript"》 //记录选区大小,位置 var rect = { left:-1, top:-1, width:-1, height:-1, start_left:-1 }; //这个我就不说了…… function $(id) { return document.getElementById(id); } //当选区改变时,改变选区的属性 document.onselectionchange=function(){ var sel = document.selection.createRange(); rect.left = sel.boundingLeft; rect.top = sel.boundingTop; rect.width = sel.boundingWidth; rect.height = sel.boundingHeight; rect.start_left = sel.offsetLeft; rect.end_left = sel.offsetTop; }; //当鼠标移动时,得到鼠标的绝对位置 document.onmousemove = function(){ var position = getMouse(window.event); if(ptInRect(rect,position)) { document.title = "鼠标在选区中!!!!!!!!!!!"; $("show").innerHTML="选择的文字是---》"+document.selection.createRange().text; } else document.title = "鼠标不在选区中"; } //判断鼠标是否在矩形(也就是选区,选区是一个矩形)内 function ptInRect(rect,pt) { if(pt.x》rect.left&&pt.x《rect.left+rect.width&&pt.x》rect.start_left) if(pt.y》rect.top&&pt.y《rect.top+rect.height) return true; return false; } //得到鼠标的位置 function getMouse(ev) { if(ev.pageX || ev.pageY) { return {x:ev.pageX, y:ev.pageY}; } return { x:ev.clientX + document.body.scrollLeft - document.body.clientLeft, y:ev.clientY + document.body.scrollTop - document.body.clientTop }; } 《/script》《/html》 跪求这种JS解密方法!!!! 麻烦大家帮我看一下这个是如何加密的,谢谢 正则求助,请教大牛救急 extjs的menu相关问题 好困难的遮罩取 子层的问题哦 如何实现向下钻取的功能! 关于用Wscript.Shell模拟键盘输入的问题,高手请进 有谁是在国外工作,能搞到空间的,我用国内的空间跟他换 奇怪的问题????? 修改 网页选中文字的样式 loadJS 【cloudgamer框架研究之 】 Array.prototype.forEach的困惑
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货