Here's an easy way to do this, which exploits the fact that setting the end of the DOM range at an earlier point in the document than the beginning of the range will change the range. I think this will break in Firefox 2, which had an error in processing it, but the number of users of this browser is tiny.
function isSelectionBackwards() { var backwards = false; if (window.getSelection) { var sel = window.getSelection(); if (!sel.isCollapsed) { var range = document.createRange(); range.setStart(sel.anchorNode, sel.anchorOffset); range.setEnd(sel.focusNode, sel.focusOffset); backwards = range.collapsed; range.detach(); } } return backwards; }
source share