简体   繁体   中英

how to fire selection event in a IE HTML editor?

Here's part of code from a IE HTML editor:

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. 

Can it be applied only to a particular element? I tryied:

$(selectStr[0], document).onselectionchange = function(){
    alert();
} // does not fire when selected.

alert($(selectStr[0], document)); // [object, object]

if $(selectStr[0], document) is changed to SOMETHING so that it alerts [object, HTMLImgElement] , the problem will be solved. Anyone knows how to do it in a correct way?

Hello friend you have to use the event " onselectstart " event in the internet explorer and for firefox u have to use " ondragstart " events to find the selection event.

Hope this helps you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM