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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T22:14:48+00:00 2026-05-21T22:14:48+00:00

I have the following content in a TinyMCE instance: <p><span id=span1>Test</span><span id=span2>Bla</span></p> When the

  • 0

I have the following content in a TinyMCE instance:

<p><span id="span1">Test</span><span id="span2">Bla</span></p>

When the user sets the cursor before the “B” and starts typing, I want the text to be typed into the second span. Google Chrome (I am using Chromium 11.0.696.65 to be exact) sets the cursor to the end of the first span, which you can verify using the following code:

document.body.innerHTML = '<p><span id="span1">Test</span><span id="span2">Bla</span></p>';
document.designMode = "on";
// Now click between the “t” and the “B”
var sel = document.getSelection();
alert(sel.baseNode.data);

Unfortunately, it does not seem to be possible to set the focus to the beginning of the second span manually:

var span = document.getElementById("span2");
sel.setBaseAndExtent(span, 0, span, 0);
alert(sel.baseNode.data); // Is still “Test”!
sel.setBaseAndExtent(span, 1, span, 1); // Move inside the span for testing
alert(sel.baseNode.data); // Now it’s “Bla”…

Google Chrome seems to move the cursor to the end of the previous node again. I have also tried to modify the Range object instead, but this resulted in the same problem.

I can’t think of any solution to this problem, does anyone have an idea what is causing this and how to fix it?

Cheers,
Candid

  • 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-21T22:14:49+00:00Added an answer on May 21, 2026 at 10:14 pm

    This is a long-standing bug in WebKit that has been frustrating rich text editor developers for years. Relevant WebKit bugs:

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

    There isn’t a decent solution, unfortunately. I have in the past resorted to tracking the cursor position, inserting a zero-width space character at the start of the current text node and removing it later once the cursor has gone elsewhere, but that’s an absolute pain to manage and is difficult to get right.

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

Sidebar

Related Questions

In an oscommerce site I have the following: Server response = Content-type: text/html;charset=UTF-8 and
I want to accomplish the following scenario in Drupal: You have 2 content-types. Lets
I have a huge bunch of XML files with the following structure: <Stuff1> <Content>someContent</name>
I have following situation: I have loged user, standard authentication with DB table $authAdapter
I have the following content in my h1 tag: (Hello World) so I add
I have defined a .dir-locals.el file with the following content: ((python-mode . ((cr/virtualenv-name .
I have the following table: content: id, user_id, markdown How do I select the
I have the following query: var content = (from ca in db.ContentAccesses where !candidateList.Contains(ca.Content)
I have an XML which has the following content: <ruletypes> <ruletype>Local</ruletype> <ruletype>Global</ruletype> ... </ruletypes>
I have a script task.sh with the following content: #!/bin/bash CUR_DIR=`pwd` SCRIPTPATH=${CUR_DIR}/`dirname $0` when

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.