The JavaScript DOM Event onselectstart
fires before the selection is changed. What if I wanted to get the new selection, check if this new selection isCollapsed
? I'll explain a little further: the user selects content on the page, firing the selectstart event; but if one wanted to see what selection did the user select, the event would still pick the selection that existed before the user fired the event...(that might be more confusing..)
Example scenario:
<div id="content">Some filler paragraph</div>
And JS:
//content is handle for div#content
// I'm not worrying about cross-compat here (.attachEvent)...
content.addEventHandler("selectstart",function(){
var nes=document.getSelection();
if(nes.isCollapsed){
// Do something
}
});
You may try handling the "mouseup" event and examining the current selection.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With