html5学习笔记4--API Range对象(一)
Range对象基本用法
效果图如下(在谷歌浏览器下的展示)
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAaoAAAC3CAIAAADM0o1QAAAIKElEQVR4nO3d244cVxWA4XonXisSmZzzFIg450i5CeFRSOKc43tAGAECZCwj5w43F5ZGnaraa686dLen1/dpZPVU7951mNQ/u1uRZjgAlDRc+gAALkP+gKLkDyhK/oCi5A8oaln+huG04wO/+s34a3bj9q/kvoLTjM96+zXZ8apCZZ0badGN3X359NmM54PXte942KwXPH+zg+UPdtG/kY5vtt3zl58hSNix7YvE0fjWLoIT2Xf1Nx0vf7CLu5e/7e9buzPcmk5yOEH+Zle78fhgfiBp58/yku9kj2eLB8/m7zAXoxULvRVvlm8PJrgsrXesrasx+wtmOmfmkgJ5Wz+bm75k9bfxlqB302dnu9YyGtNK4e6rvzh/Kx4Di2z6GP5S+ZsVrN2Sb4enOzrpZ3/yB5f1QuQv88Zw9epvtHF2THeq6avyp9m6RN38HW+RP9jd4vxl7tV138ZbVn/2d+i9n52N4O1Op+QPrkP25pm95U6Uv9l9dT/d6+Zv+my8pfX4nPmLF8jHy2Rgqf3zF2vN2Zp5lL/kp3jBgm7qxcxf60OA4DGwSOrmad1ju6z+4lauu72Tq7/WZ3yHRDFbJ5U869kHmcHxeCCvf/MEN1j33kuugzJjgmVdZvWX/Do0WjmdJDiLIH/dRbT8wdmctl8nyt9oy3TA0kTO5u+QePM7ewor8tf9fED+YHdr8pR/W9rNX8bzwZnSHcIP8gKtXAbj47ObPYXRg6Wrv/j6AEutfGObvOt2XP09l1m+ZYZtf/nS7gRLwhUvXz0PcMvNAxQlf0BR8gcUJX9AUfIHFCV/QFHyBxQlf0BR8gcUJX9AUfIHFCV/QFHyBxQlf0BR8gcUJX9AUc38PXj47PdfHi7y9eDhs3NeAqCm+fw9ePjs5rOnb3/y01sf/3jmr7c/+enms6cKCJzafP4+/+LZmx/98POFvPXxj7/7w//OfCGAapr5e+PD759eyJsf/SB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JThCvR/+ceLhdaW2e2jeyzO2V75i23P39Isdo8qrnZ+ntnBmWu4bhdw56zP3+wdlbx1g90F83RXK8HRZnYav2pFy5a+ZPrrIT6Y/HU+/mHlL5H8cd36K5duDlodzL/JiueZfTz71IqlTbBK7R72ujbNThhflvjEMwc8OqR4fPcnBdch+3FeJgdbD2Xhh3HdYd0Xzg6Io5acPH9xkldy4wXXMphySwBFyR9QlPwBRckfUJT8AUXJH1CU/AFFyR9QlPwBRckfUJT8AUXJH1CU/AFFyR9QlPwBRckfUJT8AUXJH1CU/AFFyR9QlPwBRckfUJT8AUXJH1CU/AFFyR9QlPwBRckfUJT8AUXJH1CU/AFFyR9QlPwBRckfUJT8AUXJH1CU/AFFyR9QlPwBRckfUJT8AUXJH1CU/AFFyR9QlPwBRckfUJT8AUXJH1CU/AFFyR9QlPwBRckfUJT8AUXJH1CU/AFFyR9QlPwBRckfUJT8AUXJH1CU/AFFyR9QlPwBRckfUJT8AUXJH1CU/AFFyR9QlPwBRckfUJT8AUXJH1CU/AFFyR9QlPwBRckfUJT8AUXJH1CU/AFFyR9QlPwBRckfUJT8AUXJH1CU/AFFyR9QlPwBRckfUJT8AUXJH1CU/AFFyR9QlPwBRckfUJT8AUXJH1CU/AFFyR9QlPwBRckfUJT8AUXJH1CU/AFFyR9QlPwBRckfUNT/AY3SyZRaAStSAAAAAElFTkSuQmCC" alt="" width="426" height="176" />
代码如下
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body>
<script>
function test()
{
var html="";
var showRange=document.getElementById("test");
selection=document.getSelection();
if (selection.rangeCount <= 0) {
} else {
for (var i = 0; i < selection.rangeCount; i++) {
var range = selection.getRangeAt(i);
html+="您选取的内容为["+range+"]</br>";
}
showRange.innerHTML=html;
}
}
</script>
<p>为中国奥运健儿加油</p>
<input type="button" onclick="test()" value="点击"/>
<div id="test"></div>
</body>
</html>
在火狐浏览器下的展示
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhE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kFAHGkFgDEkVoAEEdqAUAcqQUAcaQWAMSRWgAQR2oBQBypBQBxpBYAxJFaABBHagFAHKkFAHGkFgDEkVoAEEdqAUAcqQUAcaQWAMSRWgAQR2oBQBypBQBxpBYAxJFaABBHagFAHKkFAHGkFgDE/R+WPar6Eh5PmQAAAABJRU5ErkJggg==" alt="" />
为什么会出现这种情况呢,因为火狐浏览器下可以针对不连续的内容多选.
Range对象之SelectNode和selectNodeContents方法
效果图如下
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAcMAAAB/CAIAAAAcmz4zAAARsklEQVR4nO2d33MUVRbH7z+Bb/vkIz6xLyP7YgkxCVoCiuVWuQaxapEgruWDFK5ShYBllfxQXPI7kJAqTGCL9WET3HW3QPOwlvxIoUJBWFgJwiSboCxBrVp6Znofhp309L333HP79qSnO99PnQrdt8899/Tt7m+f7kkG8S0AAAA3RNIJAABA6oGSAgCAK+Lo0T/CYDAYzMWEDwAAwA0oKQAAuAIlBQAAV6CkAADgCpQUAABcgZICAIArUFIAAHAFSgoAAK5UK6kQMBgsSQPpxKykwv5sCMGMGWEgGCxrBtKJq5Iq4ZwxshvRkSD5Ux8Gi9FAOgkrKRPiVIisbrSSGpdhsCwYSCdUTSqkn0rjyy7tQIg1lBS2UAykE62SCv0CYbEUpHIQjkzDYFkwkE4USioXksFlTo1JS55Smo1KyvSEwdJtIJ1UHTlllaerEOWTgKNrQrMKJYXBfAElTSvqp3tOaRmyCDIaHCu4VafdVvnAYKk0kE60Sqo8zEQ7X+l0iin0Q6AmhS0UA+kkhpqUqYDGLkQcTkwYLAsG0olrTRosMJnKSwwhayuf5K8BGMzdQDpxqkmFZplurLQTumzsBemEZdNAOonnPalvUyrq9JeWSKFfgMGyYyCdxPZdUMyaVFfVEvoYUmSh3wSDpd5AOlH8PimT0BnAcTPWm6FV3UDKoZO/BmAwdwPpZL5rUveOEE1Ylg2kE3zTMwxWTwbSCZQUBqsnA+kESgqD1ZOBdAIlhcHqyUA6gZLCYP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S2wqUJ/RVQYzVaKidr6TEKRFs+f8IE8WWnPKhBOiAkpphygHR3RhZ6WxVRNCZEP7GjszRmUWc0ceoqvRW2xGZcaxWOePyEzMeO46S0nEkoKTWQEnN0FIYWnWsyJQ+hHIxJT40nO3NgD8QMTl8n+De6dziurdxbmMu9xKii86HuLn6jHPMl6RTN43MQw84QEnN1EIsjA4cGVVG4IgmcaFaJUm385WOvtTpLsSyDo6yuMuirb9xcuQWWjGV7S53IEAAJTUz/0pKK6PcxSgBkSUjNLSVMjJ1gehCxOHENPrr7lIuBaaxZlQOEaolaX8XJWXuBbAFSmrG9k5On6+0boZWad1hxo82BB2BaDdWQFZDyJlH0CllzMhaadxq5a+USLpvBCUNKbXSDbgAJY2faEoqn9Z80QldKlYp8ZWUI1jGyHSGxtsM0YuvCLTO8sflY3u7oqcxWk1KlKgQU3egpGboM8+qxtT562SUXwkSznK0mtakwU3MUlGXD3MSbBWB45askvrkThklkojAWfZ9v7gt55X/ogHwgJKaMZ7fVtLJKbsiVHZG0WFeQjFilbm8SksJsTucepNjtrvm7m97rG2VlDgVqzdNFFtyXuAXioERKKkB2/u8z7hQ6eE4wsq+JBRpW2XFFB1d2kY3Ylwif9pZ52YclO/DV1L6DkeHNR7rkE/o5KRvRVRWlS8rAGygpBQupYStMy1nulWmsiQCs8Jy7zj/+xvLEed48gU98s1VgeZbFwABlBQAUEVxW64wENP3Dy4YoKQAAOAKlBQAAFyBkgIAgCtQUgAAcAVKCgAArkBJAQDAFSgpAAC4AiUFAABXoKQAAOAKlBQAAFyBkgIAgCtQUgAAcAVKCgAArkBJAQDAFSgpAAC4AiUFAABXoKQAAOAKlBQAAFz5H8BP6WDUmLCgAAAAAElFTkSuQmCC" alt="" />
代码内容如下:
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body>
<script>
function deleteRangeContent(statusContent)
{
var div=document.getElementById("range");
var rangeObject=document.createRange();
if(statusContent)
{
rangeObject.(div);
rangeObject.deleteContents();
}
else
{
rangeObject.selectNode(div);
rangeObject.deleteContents();
}
}
</script>
<div style="width:300px;height: 30px;background-color: #ec7dff" id="range">查看效果</div>
<input type="button" onclick="deleteRangeContent(true)" value="删除div内部内容"/>
<input type="button" onclick="deleteRangeContent(false)" value="删除div及内部内容"/>
</body>
</html>
selectNodeContents是选定div里边的内容,selectNode是选定div包括里边的内容.
Range对象之setStart和setEnd方法
效果图如下
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZEAAACQCAIAAABGaMERAAAML0lEQVR4nO3dP3MbxxnHcb4VvAscGhfmCyBIdbY1Y1ck0aTxKI1Iiu5tTzCakSzXIvW3UilRoqhSbJMooqg4opg4HZMOIIkUq5zuz+6zzx6AOy74/QyGc7jb29vdu/3xjobguf8AQDzmmm4AAAQgswDEZO41AMRjbgQA8SCzAMSEzAIQEzILQEzILAAxIbMAxITMAhATMgtATMgsADHxZNbc3BRDbaqVT8+cm3dH7xr9Vm+xMXcXClRo9kU710J7QvuLmo2VWcLs9c7kCjPKW7myPele1dpfrUfl2iYyPqHtqdBl/QjIx3VVFTTyQY2Xq9K3X38uUINxM8t/gMBYqXaUoJJzmcyqUKdrL1fjXRMp6KAVCsuDqexXhTMSelxltRX2Kh/U24wxr0DUoIHMCq0wNIn0tWkOZ612nMCV55iG3CN5F+umoMJC+fLWciPL5TUjI9BUKCwUylfoL2oWfPtdKCzvMnJEgOsamuwF4a3NdeHKZVzVamqTW6XpvmsilQfQOj8Lu2fXu85v4W218Qnqmp68i/UyEy7pav1FzTwXXNBbzRprSFlnV7keIRk1xVxzUi6snJOu9ZoKvTXLZVyzTphyhcZYz4Wwr7492ZWusyDvKJN3KR+xvCDUpuwvatZMZmkCQrjEq81tZRlNH13k2uS+lwtba5ZHQy6ZVivX45rYynOhPIkjcSTlHb19sXZEMzjW+oUyqN9kMks5D0eOy8hVWNMGe68UN27WreXLdMxrtDxPhJmjSR/XLEp/ynNePh1C412FlbPae0aUp6xQXtn+0EYKu5NZj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ZgGICZkFICZkFoCYkFkAYkJmAYgJmQUgJmQWgJiQWQBiQmYBiAmZBSAmZBaAmJBZAGJCZgGICZkFICZkFoCYkFkAYvI/9W8JLuBU7jcAAAAASUVORK5CYII=" alt="" />
代码内容如下
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body>
<script>
function deleteFromEnd()
{
var textNode=document.getElementById("test").firstChild;
var rangeObject=document.createRange();
rangeObject.setStart(textNode,1);
rangeObject.setEnd(textNode,4);
rangeObject.deleteContents();
}
</script>
<div id="test">中国奥运军团是所向披靡的战无不胜的</div>
<button onclick="deleteFromEnd()">删除</button>
</body>
</html>
我们误以为是会删除”中国奥运”四个字,但是实际上删除的只有“国奥运”.
Range对象之setStartBefore和setEndAfter方法
效果图如下
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAW8AAAEeCAIAAADKIAMnAAAgAElEQVR4nO3deVgT96L/8Tn9Pb+epec+p/f06vP87nN6ltvec3pOj78erQoiFWUT3NHWqixulcW6UXvctai0ImJrRVyQTVGP4NJeQUSKC1VbN1QQt6qgEBIgkSQkIZCZZO4f0RizTDKTbyCBz+vJwxMmk5kvkbydmYQMxQIAkEA5nKMOALqW+5/4boGaAHgc9z/x3cJxTQoLD+GCCy5deemCZ747OK4JAIAzUBMAIAM1AQAyUBMAIAM1AQAyUBMAIAM1AQAyUBMAIENITSiALkT8lx7cRGBNiI8DwCb8snkR1AQ8Gn7ZvIhLNenW7V8vg0eML4tfNvB8rtaE6GB6LDxifOER80aoSVfAI8YXHjFvRKwmNv/Vif8qOL/ArhmPkwPAI8Z3AKiJNyJZE+v9Xns7w8KHy3kAwmJO943H5tqtB2Bz2F0zQpur9vZHDDwcmZrYe7ZYT3SF88vpmvFwL4p71XjEuG9CTbwRgZrY/B+G478d0xRu9lbq/PB4jUcYjnFyPDd6xiPGdzwcy7G+CTXxRm7c03Hmd8uVNTq8i/vGY3MVHEPFI2ZzFRxDFTB+6HbEamJvHodzCl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+rw8fVGRvSVhTwfcATXxCKY9HSYhgTX+EU1jI8uyzJo1z/9E0MmaMAw9ZIh+0yaO1b2wbWK2M4WagCtQE49gqonp/Samt70zsbFPX6xxribMggWsVqvfu5dr2wQ1ATdATTxASwuzaJHxKldNnHhnvT493VBR8fSOy5dbHov5xz8MVVWssSbHjzPLlukPHzbWxFBaqt+7l/n0U9QEBENNup/FG1UtbzXVxA57R2G57pKVZSgvNzx+zKxZ83wi/oYYXIOaAAAZqAkAkIGaAAAZqAkAkIGaAAAZqAkAkIGaAAAZqAkAkIGaAAAZqAkAkIGaAAAZqAkAkIGaAAAZqAkAkIGaAAAZqAkAkIGaAAAZqAkAkIGaAAAZqAkAkIGaAPQuSUlJbloyagLQu6AmACCceUFQEwAQKCkpCTUBAFclWXHfulATgB7O3RExQU0Aej7UBAC8CTUXO7UAAABgSURBVGoCAGSgJgBABmoCAGSgJgBABmoCAGSgJgBABmoCAGSgJgBABmoCAGSgJgBABmoCAGSgJgBABmoCAGSgJgBABmoCAGSgJgBABmoCAGSgJgBABmoCAGSgJgBAxv8CMV2ryIFcvSQAAAAASUVORK5CYII=" alt="" />
代码如下
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<style>
table,tr,td
{
border:1px solid;
}
</style>
</head>
<body>
<script>
function deleteContent()
{
var tableElement=document.getElementById("tb");
if(tableElement.rows.length>0)
{
var range=document.createRange();
var row=tableElement.rows[0];
range.setStartBefore(row);
range.setEndAfter(row);
range.deleteContents();
}
}
</script>
<table id="tb" style="border:1px solid;">
<tr>
<td>第一行第一列</td>
<td>第一行第二列</td>
</tr>
<tr>
<td>第二行第一列</td>
<td>第二行第二列</td>
</tr>
</table>
<button onclick="deleteContent()">删除table行</button>
</body>
</html>
该实例中定义了table的开始位置和结束位置来删除.
html5学习笔记4--API Range对象(一)的更多相关文章
- [html5] 学习笔记- 编辑API之Range对象(二)
本节继续介绍range对象的方法,包括cloneRange,cloneContents,extraContents,createContextual,createContextual-Fragment ...
- [html5] 学习笔记-编辑 API 之 Range 对象(一)
1.Range对象的基本概念 一个Range对象代表页面上的一段连续区域,通过Range对象,可以获取或修改网页上的任何区域. <!DOCTYPE html> <html> & ...
- Java学习笔记之---API的应用
Java学习笔记之---API的应用 (一)Object类 java.lang.Object 类 Object 是类层次结构的根类.每个类都使用 Object 作为超类.所有对象(包括数组)都实现这个 ...
- html5学习笔记一
HTML5学习笔记 <video>标记:定义视频,Ogg.MPEG4.WebM三种格式 <video src=”movie.ogg” controls=”controls”> ...
- Html5学习笔记1 元素 标签 属性
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- Java学习笔记之---类和对象
Java学习笔记之---类和对象 (一)类 类是一个模板,它描述一类对象的行为和状态 例如:动物类是一个类,动物们都有属性:颜色,动物们都有行为:吃饭 public class Dog { Stri ...
- HTML5学习笔记之表格标签
HTML5学习笔记之表格标签 其他HTML5相关文章 HTML5学习笔记之HTML5基本介绍 HTML5学习笔记之基础标签 HTML5学习笔记之表格标签 HTML5学习笔记之表单标签 HTML5学习笔 ...
- html5学习笔记5--API Range对象(二)
Range对象之cloneRange和cloneContents 代码效果如下 首次点击“选择内容“按钮提示如下 接着会显示 最后显示 以下为整个代码 <!DOCTYPE html> &l ...
- HTML5 学习笔记(一)——HTML5概要与新增标签
目录 一.HTML5概要 1.1.为什么需要HTML5 1.2.什么是HTML5 1.3.HTML5现状及浏览器支持 1.4.HTML5特性 1.5.HTML5优点与缺点 1.5.1.优点 1.5.2 ...
随机推荐
- 【转】优化Web程序的最佳实践
自动排版有点乱,看着蛋疼,建议下载中文PDF版阅读或阅读英文原文. Yahoo!的Exceptional Performance团队为改善Web性能带来最佳实践.他们为此进行了 一系列的实验.开发了各 ...
- django开发个人简易Blog——数据模型
提到数据模型,一定要说一下MVC,MVC框架是现代web开发中最流行的开发框架,它将数据与业务逻辑分开,减小了应用之间的高度耦合.个人非常喜欢MVC开发框架,除了具有上述特性,它使得web开发变得非常 ...
- HttpContext.Current:异步模式下的疑似陷阱之源
最近园子里首页有好几篇文章都是讲异步编程的,尤其是几篇讲博客园自身的异步化建设的文章,看了以后很有收获. 闲暇之余再重新查查资料温故知新学习一遍,重新认识了SynchronizationContext ...
- 实战使用Axure设计App,使用WebStorm开发(2) – 创建 Ionic 项目
系列文章 实战使用Axure设计App,使用WebStorm开发(1) – 用Axure描述需求 实战使用Axure设计App,使用WebStorm开发(2) – 创建 Ionic 项目 实战使 ...
- WebKit技术内幕
WebKit技术内幕(浏览器内核|渲染引擎| HTML5| Chromium项目Committer重磅作品) 朱永盛 著 ISBN 978-7-121-22964-0 2014年6月出版 定价:7 ...
- Java正则表达式应用详解
如果你曾经用过Perl或任何其他内建正则表达式支持的语言,你一定知道用正则表达式处理文本和匹配模式是多么简单.如果你不熟悉这个术语,那么“正则表达式”(Regular Expression)就是一个字 ...
- Android笔记——了解SDK,数据库sqlite的使用
一.adb是什么? adb的全称为Android Debug Bridge,就是起到调试桥的作用.通过adb我们可以在Eclipse中方面通过DDMS来调试Android程序,说白了就是debug工具 ...
- Java 多态——与C++的比较
学习了Java和C++之后,由于长期不使用C++,而java的基础知识掌握不牢,现在已经搞不清java多态了.现在先来谈谈java多态,稍后有时间再更新C++的多态,并进行比较~ 一. Java的多态 ...
- UML快速回顾
UML(Unified Modeling Language)统一建模语言的概念已经出现了近20年,虽然并不是所有的概念都非常有实践意义,但常见的用例图.类图.序列图和状态图却实实在在非常有效,是项目中 ...
- 选择排序java代码
/** * 选择排序 * * 原理:将最小值与数组第1个即array[0]交换,第二次则忽略array[0],直接从array[1]至array[array.length-1]中 * 选择出最小值与a ...