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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:40:06+00:00 2026-05-27T04:40:06+00:00

html that is being selected: some te<b>xt here is bold</b>ed, I guess |______________________| <-

  • 0

html that is being selected:

some te<b>xt here is bold</b>ed, I guess
              |______________________|  <- the selection range

so, the selected .toHtml() is this:

<b>ere is bold</b>ed, I gue

but this is not in the original document.

So, what I want to do is expand the selection so that it contains the entire BOLD tag.

This is easy to detect, as you just need to do a test if

a = rangy.getSelection()
a.anchorNode.parentElement != a.focusNode.parentElement

The documentation states that rangy ranges have a setStartBefore(Node) method : http://code.google.com/p/rangy/wiki/RangyRange

so, I get the current range

b = a.getRangeAt(0)

and try to setStartBefore :

b.setStartBefore(a.anchorNode.parentNode)

and since I’m doing this all in the console, I get the immediate feedback saying

undefined

what would be causing this, and how I would go around it to find a solution for the problem I want to solve?

UPDATE:
as per Tim Down’s suggestion, I’ve tried the following:
enter image description here
Original Text:
enter image description here

It should have expanded to include Mass Ef shouldn’t it have?

UPDATE 2:

The solution (as per Tim Down)
enter image description here

  • 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-27T04:40:06+00:00Added an answer on May 27, 2026 at 4:40 am

    You need to reselect the range:

    a.setSingleRange(b);
    

    By the way parentElement is not universally supported: it started out IE only, has relatively recently made it into the DOM4 spec and is not yet supported in Firefox (support is coming in Firefox 9.0, apparently). You’ll need a workaround based on parentNode and nodeType.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some HTML that looks like this: <ul class=faq> <li class=open> <a class=question
If I have some HTML that looks like this: <div id=text> This is some
I have some HTML that looks like this: <div> <div class=value> <a href=# class=clicker>Some
I have some javascript that looks like this: var sel = '<option value={value} {selected}>{name}</option>';
I have some javascript that manipulates html based on what the user has selected.
I am trying to capture urls in an html page that is being repeated
I have a PDF that is being generated from HTML source using HTMLDOC. While
I have an html table containing values that are being generated from javascript. How
I have some HTML that displays fine on FireFox3/Opera/Safari but not with IE7. The
I have some HTML that I need to toggle between two structures - one

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.