Been searching online for a while and I can't seem to find any decent solutions that work in both Firefox and IE --> basically I want to write a very simple WYSIWYG text editor where a user can highlight a word, click a "B" button and it adds bold tags around it.
Anybody have any idea how to accomplish this seemingly easy task? I've looked at the source code for various open source apps (like Wordpress and phpBB) but the code in both of these is gargantuan and fairly difficult to follow with all the includes and custom objects, functions etc.
It's clearly possible... anybody know how to do it?
Problem solved with a few lines of code between original post and now.
Now, onto the next issue (may post in a thread of it's own...):
When a user clicks the "B" (bold) button, I'd like the caret/text position/whatever to sit between the two tags so the user can instantly type the content of the bold text instead of having to click between the tags first.
Also, is it possible to prevent whitespace from being selected when a user double-clicks a word in a textarea field? For example, clicking the word "hello" would actually select "hello " (whitespace character at the end of the string).