Chrome是否支持document.selection? [英] Does chrome supports document.selection?

查看:490
本文介绍了Chrome是否支持document.selection?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是JavaScript新手,试图执行:

  document.selection.createRange(); 

document.selection 总是返回 undefined



我正在使用最新版本的chrome。

我做错了什么?



谢谢!

解决方案

window.getSelection(),它是跨浏览器兼容性最强的版本(它在所有主流浏览器的当前版本中都受支持)并且是标准。 Chrome肯定会像其他浏览器一样支持它。

document.selection 只能用于IE< 9。

I am new to javascript, trying to perform:

document.selection.createRange();

but document.selection always returns undefined.

I am using latest version of chrome.

what am I doing wrong?

thanks!

解决方案

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 should only be used for IE < 9.

这篇关于Chrome是否支持document.selection?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆