以下是 IE HTML 编辑器中的部分代码:
var selectStr = [];
selectStr.push("img[control_type='video']");
$(selectStr[0], document).selectionchange(function() {
alert();
}); // Explorer error: does not support this method or object.
// It seems JQuery does not support 'selectionchange' event.
document.onselectionchange = function(){
alert();
} // this works for all elements in the editor.
它可以只应用于特定元素吗?我尝试过:
$(selectStr[0], document).onselectionchange = function(){
alert();
} // does not fire when selected.
alert($(selectStr[0], document)); // [object, object]
如果将$(selectStr[0], document)
更改为SOMETHING
,以便它提醒[object, HTMLImgElement]
,问题将会得到解决。有人知道如何以正确的方式做到这一点吗?
最佳答案
您好, friend ,您必须在 Internet Explorer 中使用“onselectstart”事件,对于 Firefox,您必须使用“ondragstart”事件来查找选择事件。
希望这对您有帮助。
关于javascript - 如何在 IE HTML 编辑器中触发选择事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7174414/