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 992887
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:20:09+00:00 2026-05-16T06:20:09+00:00

Does anyone know of any cross-browser user selection range libraries written in javascript? I

  • 0

Does anyone know of any cross-browser user selection range libraries written in javascript?

I found a few jQuery plugins, (which quite frankly are too limiting and very buggy).

I would just like to know what you have found out there. Don’t send me googling this again, (I’ve spent days working on all this). Hopefully, this can be where future programmers can find the answer.

  • 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-05-16T06:20:10+00:00Added an answer on May 16, 2026 at 6:20 am

    I’ve developed a cross-browser Range and selection library called Rangy. Its core is not dissimilar in concept to IERange but goes beyond it in terms of implementation of the DOM level 2 Range and HTML5 selection specifications, and also in terms of stability and workarounds for browser bugs. I think it’s the best there is out there.

    There are also extra modules for saving, restoring and serializing selections and applying CSS class to ranges and selections.

    https://github.com/timdown/rangy

    The following uses some Rangy extensions to Ranges to easily iterate over text nodes within a selection and surround each one:

    function surroundSelectedText(templateElement){
        var range, sel = rangy.getSelection();
        var ranges = sel.getAllRanges();
        var textNodes, textNode, el, i, len, j, jLen;
        for (i = 0, len = ranges.length; i < len; ++i) {
            range = ranges[i];
            // If one or both of the range boundaries falls in the middle
            // of a text node, the following line splits the text node at the
            // boundary
            range.splitBoundaries();
    
            // The first parameter below is an array of valid nodeTypes
            // (in this case, text nodes only)
            textNodes = range.getNodes([3]);
    
            for (j = 0, jLen = textNodes.length; j < jLen; ++j) {
                textNode = textNodes[j];
                el = templateElement.cloneNode(false);
                textNode.parentNode.insertBefore(el, textNode);
                el.appendChild(textNode);
            }
        }
    }
    
    var span = document.createElement("span");
    span.style.color = "green";
    span.style.fontWeight = "bold";
    
    surroundSelectedText(span);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone know of any good resources for learning about cross-browser development in ASP.NET?
Io is a nice cross-platform prototype-based object-oriented language. Does anyone know of any GUI
Does any one know of any cross platform c/c++ libraries which will utilise the
Does anyone know any good resources with tasks or problems to get practice in
Does anyone know any site or book that presents problems like python challenge ,
Does anyone know any more details about google's web-crawler (aka GoogleBot)? I was curious
does anyone know any sort of app that lets users visit a page on
Does anyone know any open source project or adapter for MySQL-AdWhirl? We try to
Does anyone know any bugs/tricks when using scale_colour_manual to set colors to predefined settings
Possible Duplicate: PHP: Script for generating Crossword game? Does anyone know any PHP-based simple

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.