Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7971799
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:42:46+00:00 2026-06-04T07:42:46+00:00

In programmatically defining a range/selection in JavaScript, is it not possible to have the

  • 0

In programmatically defining a range/selection in JavaScript, is it not possible to have the focusOffset in the range be before the anchorOffset? How do we define a right to left selection then?

a JS fiddler link for example: http://jsfiddle.net/johncch/ejVab/1/

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T07:42:48+00:00Added an answer on June 4, 2026 at 7:42 am

    The way to create a “backwards” selection is slightly non-obvious. It can’t be done by simply selecting a Range via the selection addRange() method because ranges are intrinsically directionless. You need to use the extend() method of the selection (example below).

    Note this doesn’t work in any version of IE, including 9: unlike previous versions, IE 9 does have standard selection and range objects but at the time Microsoft was developing IE 9, extend() was non-standard so they didn’t implement it, meaning that there is no way to create a backwards selection programmatically in any version of IE yet released. IE 10 did not implement extend(), despite my filing a bug on the IE bug tracker.

    function selectRangeBackwards(range) {
        var sel = window.getSelection();
        var endRange = range.cloneRange();
        endRange.collapse(false);
        sel.removeAllRanges();
        sel.addRange(endRange);
        sel.extend(range.startContainer, range.startOffset);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to define a dojo/method programmatically, in a JavaScript function? (Instead
Is it possible to hide dock icon programmatically on demand. I know one way
If I am creating a website in ASP.NET, is it possible to programmatically set
I set views programmatically. Here is how I do that. Let's say I have
How to programmatically install Windows Media player using .net. Windows media player is not
I'm trying to programmatically add an identity column to a table Employees. Not sure
Programmatically, which is better for SEO purposes: defining web page titles client side (e.g.,
Possible Duplicate: Detecting endianness programmatically in a C++ program I am working on a
Is this possible programmatically? Getting the names of stored queries or checking if a
Possible Duplicates: How to programmatically download image from website ? Download all images from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.