chrome是否支持document.selection ?
Does chrome supports document.selection?
我是javascript新手,试图执行:
document.selection.createRange();
但是document.selection
总是返回undefined
。
我用的是最新版的chrome。
我做错了什么?
谢谢!
使用window.getSelection()
,这是最跨浏览器兼容的(在所有主要浏览器的当前版本中都支持),并且是标准。Chrome当然像其他浏览器一样完全支持它。
document.selection
只能用于IE <9 .
试试document.getSelection()
或window.getSelection()
。
下面是我在chrome中测试的一个快速示例
http://jsfiddle.net/hgDwx/浏览器对基于IE11和Chrome 87.04280.141的selection
对象的支持
<表类>
成员IE 铬
tbody> <<tr> 对 没有道明> tr> 没有道明> 有道明> tr> 没有道明> 没有道明> tbody> 表类>
document.selection
window.selection
document.getSelection()
window.getSelection()
用window.getSelection()
代替。
相关文章:
- 正在寻找比$(document).ready慢的$(window).load的替代方案
- 将jsp文件下拉列表中的选定项分配给一个java变量(比如String selection)
- document.open/document.write没有正确地清除chrome中的文档——这是chrome的错误吗
- 如何用更合适的内容替换document.write
- 需要垫片设置-jquery.flot/jquery.flot.selection
- document.styleSheets不返回任何内容
- jQuery document.ready not working
- $(document).height()在刷新时随机化值(Safari 5.1.10)
- reactjs this.refs vs document.getElementById
- Bootstrap Dropdown selection是在*all*下拉菜单上设置选择
- 如何通过adf中的document.getElementById获取inputText字段值
- window.opener.document在ie中不起作用
- contentWindow.document.body is null
- document.applet.method在Mounatin Lion上抛出safari 6+JDK7异常
- document.getElementById(“st”).click();不起作用
- $(document).height和$(window).heaght都返回相同的值-使用的是正确的doctype
- jQuery document.ready停止代码
- document.getElementById并使用id名称
- document.selection.createRange()在chrome和safari中不工作
- chrome是否支持document.selection ?