javascript: create range from cursor position at time a to cursor position at time b <p>I get the cursor position at time a. Then I get the cursor position at time b. I want to make a range from the cursor position at time a to the cursor position at time b. Time a and b are start and end of ctr-v (paste).</p> <p>I get the cursor position like so - or rather a range at the cursor position.</p> <pre><code>sel = window.getSelection(); range_time_a = sel.getRangeAt(0).collapse(true); </code></pre> <p>But, how do I use range_time_a and range_time_b to create a new range that starts at range_time_a and ends at range_time_b? </p> <p>I have seen code to get the element with the cursor and to get the offset within that element. I could use that for setStart() and setEnd, but it seems like there should be an easier way since I've already got two ranges.</p>