I use the execCommand function in javascript to build a WYSIWYG editor where you can write text, format it, change HTML-source behind and so on..
Now I want it to work as Word, meaning: when the cursor is placed on some text, the appropriate buttons will be pushed down (this text is: Bold, Underlined, size..). How do I get the tags that affect the text and what event can I use (should be changed everytime user clicks or moves the cursor with arrows) ??
You could use queryCommandState("bold") to get the state of commands which only have on and off and queryCommandValue("fontsize") to get the value of commands which has more than one option.
I was building a bit more complicated solution using TextRange and parentElement() to find out the tags, that would have been perfect if it wasn't for the very strange and buggy behavior that moveToElementText() function is displaying..
Your functions was a lot easier to use and seems more reliable, but is there any way to detect eg images and hyperlinks with them? (or something else) They worked great on bold,italic,underline,font etc, but I haven't found any solution for non-text-stuff
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.