一、document.selection 介绍
document.selection 表示当前网页中的选中内容。
方法有:
clear 清除选中的内容
empty 取消选中
createRange 返回 TextRange 或 ControlRange 对象
createRangeCollection 不支持
属性有:
type 选中内容的类型
typeDetail 不支持
二、document.selection.createRange()详细介绍
document.selection.createRange() 根据当前文字选择返回 TextRange 对象,或根据控件选择返回ControlRange 对象。
配合 execCommand,在 HTML 编辑器中很有用,比如:文字加粗、斜体、复制、粘贴、创建超链接等。
例子:
Html代码 收藏代码
document.selection 表示当前网页中的选中内容。
方法有:
clear 清除选中的内容
empty 取消选中
createRange 返回 TextRange 或 ControlRange 对象
createRangeCollection 不支持
属性有:
type 选中内容的类型
typeDetail 不支持
二、document.selection.createRange()详细介绍
document.selection.createRange() 根据当前文字选择返回 TextRange 对象,或根据控件选择返回ControlRange 对象。
配合 execCommand,在 HTML 编辑器中很有用,比如:文字加粗、斜体、复制、粘贴、创建超链接等。
例子:
Html代码 收藏代码