This is a migrated thread and some comments may be shown as answers.

Get/Set HTML Firefox

1 Answer 87 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Justin
Top achievements
Rank 1
Justin asked on 13 Apr 2011, 09:35 PM
I have recently took over a project from someone else and am experiencing some inconsistencies when it comes to getting/setting html in firefox. 

When i use get_html i want to always have my content wrapped in HTML tags. So if i type a few words it should be wrapped a <p> tag when i use get_html. This works for hte most part but with a couple inconsistencies:

1) When i set my HTML using set_html , if my content is empty i must set "<p>&nbsp;</p>"  or else setting it to empty text will just return straight text when i use get_html if i just type a few words without any styling/line breaks.
2) Setting it to <p>&nbsp;</p> when the content is empty works fine when i use get_html. Everything is wrapped in a <p> tag how i want it but if i highlight/delete the content then start again sometimes (but not always) the <p> tags disappear and i get straight text and no HTML. 
3) If i use <p></p> in Firefox when i have no content to set the return results are "<p></p>" then my text, but in IE the text appears inside the <p> tag. 

I really just want to enforce always having formatted HTML when i use get_html. No text should be coming back outside of html tags. 

I have the following ContentFilters set up:
ContentFilters="ConvertCharactersToEntities,ConvertFontToSpan,ConvertToXhtml,FixUlBoldItalic,OptimizeSpans,RemoveScripts"

Also not sure if this is a big deal but the editor is in a jquery dialog and the content is set on button click like so:

if (content == "" || content == null || jQuery.trim(content) == "") {
    content = "<p>&nbsp;</p>";
 }
 
$("#telerik-editor").dialog("option", "title", title);
$("#telerik-editor").dialog("open");
 
var editor = $find("<%= radEditor.ClientID %>");           
editor.set_html(content);
 
$('input:visible').eq(0).trigger('focus');
 
setTimeout(function(){ 
    editor.setFocus(); 
    if ($telerik.isFirefox){ 
        setTimeout(function(){ 
            editor.pasteHtml(""); 
            editor.undo(1); 
        }, 200); 
    };               
},200);

i know there are some known issues with the version of firefox i am using (3.6.15) and the editor as you can tell by the focus trick needed to get it to work. I just want to see if there are any other ways to go about doing what i want. thanks

1 Answer, 1 is accepted

Sort by
0
Dobromir
Telerik team
answered on 18 Apr 2011, 01:03 PM
Hi Justin,

This is not directly related to RadEditor but is a standard browser behavior. RadEditor's content area is an editable <iframe> and the editor is based on the browser's default Rich Text Editing engine, and different browsers are handling the entered content differently. By default, Internet Explorer wraps any entered content in the editable <iframe> with a <p> element, while Firefox is entering the content directly inside the <body> tag.

All the best,
Dobromir
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Editor
Asked by
Justin
Top achievements
Rank 1
Answers by
Dobromir
Telerik team
Share this question
or