站长资源网络编程
javascript中获取选中对象的类型
简介在Javascript中 利用 document.selection 可以创建 textRange。 但其实不是什么时候都可以创建的。 我们可以利用 document.selection.type 来判断当前选中的是文本还是对象。 document.selection.type 返回三个值 "Non
在Javascript中 利用 document.selection 可以创建 textRange。 但其实不是什么时候都可以创建的。
我们可以利用 document.selection.type 来判断当前选中的是文本还是对象。
document.selection.type 返回三个值 "None" "Text" "Control"
只有当返回值是 Text 时,创建的textRange才是有效的。
我们可以利用 document.selection.type 来判断当前选中的是文本还是对象。
document.selection.type 返回三个值 "None" "Text" "Control"
只有当返回值是 Text 时,创建的textRange才是有效的。