Get/Set HTML Firefox

2 posts, 0 answers
  1. Justin
    Justin avatar
    5 posts
    Member since:
    Aug 2010

    Posted 13 Apr 2011 Link to this post

    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
  2. Dobromir
    Admin
    Dobromir avatar
    1633 posts

    Posted 18 Apr 2011 Link to this post

    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.

Back to Top