javascript - 如何在 IE HTML 编辑器中触发选择事件?

标签 javascript jquery editor

以下是 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/

相关文章:

javascript - 如何在jsPdf表格中设置表格

javascript - 无法将 EventListener 添加到 javascript 中的对象

javascript - 更改表格中的单元格颜色

javascript - FullCalendar jquery 没有加载我日历中的事件

linux - 在 Linux 中编写经典 ASP

javascript - 从 Three.js 编辑器导出场景并导入

javascript - 删除包含重复单元格的行

Javascript - 根据设备更改按钮图像

vim - 如何用vim粘贴新行?

javascript - 如何使用 ssh2 和 node.js 计算远程服务器上的磁盘空间并存储值?