Skip to content
Advertisement

HTML5 event for `onselectionchange`

Is there a standard cross-browser HTML5 event which corresponds to IE legacy onselectionchange (so it is fired when the current selection changes)?

EDITED, I’m looking to track Selection object changes.

Advertisement

Answer

use onchange

I recommend using jQuery to avoid these cross browser issues, but that does not mean you should skip testing. see here.

Look at Rangy window.getSelection = rangy.getSelection

it might work…

/* 
IE 8 getSelection() missing object and properties simple hack
*/
if (window.getSelection == undefined) {                /* IE? */
    var wgS = setInterval(function(){                  /* wait for Rangy */
        if (rangy.initialized) {
            window.getSelection = rangy.getSelection;  /* do the stuff */
            clearTimeout(wgS);                         /* exit */
        }
     }, 10);
}

Source : Web

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement