have a heart (and some tact)

nice article. I appreciate the in-depth examples.

ps said on September 17, 2004

Hi Jonathan,

Thanks so much. This was very helpful. Your article gave me the clue as to how to approach this issue which I could not get elsewhere. However, I use bookmarks instead of text as it produces flickering in my tool.


Diederik Stenvers said on December 01, 2004

Well, it worked after a few changes (obvious ones, like the name of controls), i am very happy with this article that rocks!

Arjan Haverkamp said on December 18, 2004


the regular expression you use to determine whether the cursor is inside a HTML-tag is incorrect.

You have this:
var cursphrase = /(>[^<]*?)(##_CURSORPOSITION_##)([^>]*?<)/

While it should be:
var cursphrase = /(<[^>]*?)(##_CURSORPOSITION_##)([^<]*?>)/;

Jonathan Snook said on December 20, 2004

Thanks a bunch Arjan. I guess I mistyped the gt and lt's when I did the article.

Benyi Robert said on January 11, 2005

Can this be done in simple javascript?
I could not done it.
I don't even think it's impossible, but i would be quite glad if someone could contradict me.

Jonathan Snook said on January 11, 2005

Benyi: I'm not sure what you're reffering to. The cursor position code in the article is in javascript.

brendan said on January 23, 2005

var rng = sel.createRange();

Does anyone know what the return type is for this? i'm using c# and u can't just declare var.

thanks a lot.

brendan said on January 23, 2005

oh dont worry i found it :)



Andy said on February 02, 2005

Hi Jonathon,

I have only just come across your site in the last few days whilst doing some research into MSHTML. Just wanted to say thanks as all the stuff you have on here has been very helpul.

Also wanted to say(as you are clearly to nice to do it yourself) that if Daniel doesn't understand the articles, he's an idiot and should find himself another career that doesn't involve the use of a computer. I know his post was a long time ago now but people submitting abusive posts to such a helpful site is really offensive.

You have my full appreciation, respect and support.

Randy said on July 29, 2005

Hi Jonathan,

Not sure if I can use this code for my purpose but it seems like it can be tweaked. I don't really need to switch between design view and source. What I do need it when I select a word or more in the design view is to figure out is what the character position of the word I selected in Javascript.


"The big brown fox jumped over the lazy"

I select 'fox' which is the 16th character. I what 16 to be returned.

This is a great site. Keep it up. And that Daniel-what an asshole.

Christoph said on August 22, 2005

Great help. I am working on a html editor. This was the help i needed to solve my problem. Thank you very much and keep the good work up please.
Also i cant understand Daniel, i think he just needs more time and calmness while reading your article. I needed too, but finally it worked :-)
Greetings from germany

Adrenalin said on September 04, 2005

Your arcticle help me a lot!
Thank you, i'm from Moldova :)
And this is very original site..

Mike McCartney said on December 18, 2005

Robert Benyi, amigo mio, puta su madre!!


Amol said on January 09, 2006

it's very useful content

vutuanduc said on May 21, 2006

Hi Jonathan,
Thanks for your arcticle, it's help me solved my problem. Your arctical is very useful.

I'm from VietNam.

Joshua Li said on August 16, 2006

Thank you. It helps me a lot.

Sorry, comments are closed for this post. If you have any further questions or comments, feel free to send them to me directly.