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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:35:14+00:00 2026-06-04T18:35:14+00:00

I’ve noticed this problem when trying to insert a node before an empty element

  • 0

I’ve noticed this problem when trying to insert a node before an empty element when at the start of another element (pipe | is the caret position). Starting with this:

<p>|<span />Some text</p>

I used range.insertNode() on a Rangy range to paste some text, but in Chrome I see this result where the new node appears after the empty <span>:

<p><span />|INSERTED TEXTSome text</p>

Rather than this:

<p>|INSERTED TEXT<span />Some text</p>

Note that this appears to work correctly in IE9, and if the insert is not done at the start of the <p> node it also works in Chrome, e.g.:

<p>Some |<span />text</p>

results in:

<p>Some |INSERTED TEXT<span />text</p>

This is a simplified example, but shows the issue I’m seeing.

To clarify (and in case I’m approaching this the wrong way someone can suggest an alternative) I’m attempting to insert text and always have the cursor appear at the end of the newly inserted text once the insert is completed.

E.g. <p>|Original Text</p> should become <p>INSERTED TEXT|Original Text</p>

However, inserting a node results in the caret being placed immediately before the inserted text (which is as the documentation states it should be for inserting a node, so no complaint there). I am attempting to use the empty <span> as a marker to restore the caret position after the insert (in fact I’m using Rangy’s selection save and restore module to do it for me).

  • 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-04T18:35:15+00:00Added an answer on June 4, 2026 at 6:35 pm

    This is because WebKit doesn’t consider the position before the <span> to be a valid caret position. It’s related to these Webkit bugs:

    • https://bugs.webkit.org/show_bug.cgi?id=23189
    • https://bugs.webkit.org/show_bug.cgi?id=15256

    If the range is as you expect, Rangy will allow you to insert the node where you want but if you’ve got the range from the selection then the range will reflect the browser’s idea of the selection. There may be a way around it but I’m not quite clear on exactly what you’re trying to do.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I am currently running into a problem where an element is coming back from
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,
Specifically, suppose I start with the string string =hello \'i am \' me And
I have this code to decode numeric html entities to the UTF8 equivalent character.

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.