突出显示/选择多个具有可信范围的div? [英] Highlight/select multiple divs with ranges w/ contenteditable?
本文介绍了突出显示/选择多个具有可信范围的div?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设我有一套 contenteditable =true
divs。
Let's say I have a set of contenteditable="true"
divs.
<div id="0" contenteditable="true"></div>
<div id="1" contenteditable..></div>
<div...etc></div>
我不能有一个div,必须有多个div。我怎样才能突出显示多个div的内容?使用范围?还有什么吗?
I can't have one div, multiple divs is a must. How could I highlight the content of more than one div? Using ranges? Anything else?
推荐答案
答案是它取决于浏览器。有关使用Ranges的两种方法的测试,请参见此示例。第一次尝试为每个可编辑的< div>
创建一个范围,并将所有这些添加到选择中。第二次尝试创建一个Range,包含两个可编辑的< div>
s的内容。
The answer is that it depends on the browser. See this example for a test of two methods using Ranges. The first attempts to create a Range per editable <div>
and add all of them to the selection. The second attempts to create a single Range encompassing the contents of two editable <div>
s.
结果:
- 在所有浏览器中,用户无法创建存在于多个可编辑元素中的选择;
- Firefox是主流浏览器中最宽松的。两种编程方法都有效。
- Safari和Chrome是最不宽容的:两种方法都不会从多个可编辑元素中选择内容。
- Opera 11不在选择中支持多个范围,但支持跨越多个可编辑元素的选定范围。
- IE版本9之前版本不支持DOM范围或相同
选择
API作为其他浏览器,但等效的TextRange
代码不允许从多个可编辑元素中进行选择。
- In all browsers, it is impossible for the user to create a selection that lives in more than one editable element;
- Firefox is the most permissive of the major browsers. Both programmatic methods work.
- Safari and Chrome is the least permissive: neither method selects content from more than one editable element.
- Opera 11 does not support multiple Ranges in the selection, but does support a selected Range spanning more than one editable element.
- IE pre-version 9 does not support DOM Range or the same
Selection
API as other browsers, but the equivalentTextRange
code does not allow selection from more than one editable element.
这篇关于突出显示/选择多个具有可信范围的div?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文