chrome 支持 document.selection 吗? [英] Does chrome supports document.selection?
本文介绍了chrome 支持 document.selection 吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是 JavaScript 新手,正在尝试执行:
I am new to javascript, trying to perform:
document.selection.createRange();
但是 document.selection
总是返回 undefined
.
我使用的是最新版本的 chrome.
I am using latest version of chrome.
我做错了什么?
谢谢!
推荐答案
使用 window.getSelection()
,它是最具跨浏览器兼容性的(所有主要浏览器的当前版本都支持它)) 并且是标准.Chrome 当然像其他浏览器一样完全支持它.
Use window.getSelection()
, which is the most cross-browser compatible (it's supported in the current versions of all major browsers) and is the standard. Chrome certainly supports it as fully as other browsers.
document.selection
应该只用于 IE <9.
document.selection
should only be used for IE < 9.
这篇关于chrome 支持 document.selection 吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文