清除Firefox中的选择
|
我有这个功能
function smth() {
var container = null;
var newContainer = null;
if (window.getSelection) { // all browsers, except IE before version 9
alert(\"first if\");
var selectionRange = window.getSelection();
if (selectionRange.rangeCount > 0) {
var range = selectionRange.getRangeAt(0);
container = range.commonAncestorContainer;
newContainer = container;
}
}
else {
if (document.selection) { // Internet Explorer
alert(\"second if\");
var textRange = document.selection.createRange();
container = textRange.parentElement();
}
}
if (newContainer) {
return newContainer.nodeName;
}
else {
alert(\"Container object for the selection is not available!\");
}
}
现在,在我完成选择之后,我需要清除它。我尝试了几件事没有用,有什么想法吗?
document.selection.clear ()
这没有用。
没有找到相关结果
已邀请:
3 个回复
赐黄
对于其他浏览器:
参见http://help.dottoro.com/ljigixkc.php
目浆搽
或
一起使用,因为在Firebox中未选择该元素,因此诀窍是通过将所有大小属性强制为
使其不可见。
裸雷胜檀哭
如果那不起作用,那么使用