<script>
document.body.onload = tt;
function tt()
{
alert('dddddddd');
}
var b;
function te() //onselect事件
{
b=1;
}
function a() //onmouseup事件
{
if (b==1){
alert(document.selection.createRange().text);
b=0;
}
}
</script>
<body onselect ="JavaScript:te();" onmouseup ="JavaScript:a();">
onselectstart ="alert('开始');"
onmouseup="alert(document.selection.createRange().text);"
//firefox使用 window.getSelection()
网页测试测试测试才儿时才扼杀
<br>
dddddddddddddddd
<SCRIPT LANGUAGE="JavaScript">
function SelText(){
document.selection.createRange();
document.all.TestText.value = unescape(document.selection.createRange().text);
alert("选区左侧宽度:"+ document.selection.createRange().boundingLeft);
alert("选区上方高度:" + document.selection.createRange().boundingTop);
alert("选区高度:" + document.selection.createRange().boundingHeight);
alert("选区宽度:" + document.selection.createRange().boundingWidth);
}
</script>
<input type="text" id="TestText" name="TestText" value="" accesskey="A">
<input type="button" name="btnTest" value="Test" onclick="SelText()">
<hr>
对象: document.selection.createRange(); 返回TextRange 对象<br>
TextRange 属性<br>
boundingHeight 获取绑定 TextRange 对象的矩形的高度。 <br>
boundingLeft 获取绑定 TextRange 对象的矩形左边缘和包含 TextRange 对象的左侧之间的距离。 <br>
boundingTop 获取绑定 TextRange 对象的上边缘和包含 TextRange 对象的顶边之间的距离。 <br>
boundingWidth Retrieves the width of the rectangle that bounds the TextRange object. <br>
htmlText 获取绑定 TextRange 对象的矩形的宽度。 <br>
offsetLeft 获取对象相对于版面或由 offsetParent 属性指定的父坐标的计算左侧位置。<br>
offsetTop 获取对象相对于版面或由 offsetTop 属性指定的父坐标的计算顶端位置。 <br>
text 设置或获取范围内包含的文本。 <br>
</body>
[Javascript]测试划词搜索
相关推荐
- Cursor 全自动代码生成器?你还没用过?接下来我就来介绍智能 AI 代码生成工具 Cursor 安装和使用 - 掘金
- 【Windows】文件夹被占用删除不掉_Energet!c的博客-CSDN博客
- docfile已损坏 docfile has been corrupted visual studio 2022
- Lodop谷歌浏览器无法打印,解决谷歌浏览器最新chrome94版本CORS跨域问题 - 知乎
- Aspnet Mvc 前后端分离项目手记(二)关于token认证 - 小小爵 - 博客园
- 尝试打开或创建物理文件时,CREATE FILE遇到操作系统错误5 (拒绝访问_麻木博客-CSDN博客
- 智能盘点-钢筋数量AI识别-目标检测实践 - 知乎
- AngularJs版本升级项目build后报错Error: [$injector:unpr] Unknown provider: e