Having trouble replacing a selected text within FCKeditor in IE.
When a button is pressed, I want it to grab the selected text and wrap it with some HTML tag. I'm using this to get the selected text:
And this to replace the selected text (note that I'm just using a p tag as an example):
The problem in IE is, the getSelection() does not grab HTML entities, while the InsertHtml() will replace the selected section, INCLUDING HTML entities. For example, say I have this in my FCKeditor field (in source mode):
In WYSIWYG mode, I highlight the word FCKeditor and click my button. Instead of just replacing the FCKEditor word, it removes the <a> tag and all I'm left with is:
Note that in Firefox, it works completely fine. The <a> tag is left intact when I click my button.
Any ideas how I can achieve this feature?
When a button is pressed, I want it to grab the selected text and wrap it with some HTML tag. I'm using this to get the selected text:
select = oFCKEditor.EditorWindow.getSelection();
And this to replace the selected text (note that I'm just using a p tag as an example):
oFCKEditor.InsertHtml("<p>" + select + "</p>")
The problem in IE is, the getSelection() does not grab HTML entities, while the InsertHtml() will replace the selected section, INCLUDING HTML entities. For example, say I have this in my FCKeditor field (in source mode):
<a href="www.fckeditor.net">FCKeditor</a>
In WYSIWYG mode, I highlight the word FCKeditor and click my button. Instead of just replacing the FCKEditor word, it removes the <a> tag and all I'm left with is:
<p>FCKeditor</p>
Note that in Firefox, it works completely fine. The <a> tag is left intact when I click my button.
Any ideas how I can achieve this feature?
Re: Problem replacing selected text in IE
Try my 'HOWTO - Work with the selection in the editor', viewtopic.php?f=6&t=806
Or look at existing code to see how it is done there.
I also have a snippet that gets the HTML of the selection, only not on this PC. PM me or reply on this topic to remind me to look it up for you.