Home / Community & Support / Knowledge Base / RadControls for ASP.NET and ASP.NET AJAX / Editor / <br> tags added to empty table cells in Firefox

<br> tags added to empty table cells in Firefox

Article Info

Rating: Not rated

Article information

Article relates to

 RadEditor for ASP.NET AJAX
 Telerik.Web.UI

Created by

 Rumen Zhekov


PROBLEM
<br> tags added to empty table cells in Firefox

DESCRIPTION
If the ConvertToXhtml content filter of RadEditor is turned OFF, then Firefox will automatically put a <br> tag to every cell in a table element. For example if the the following code is pasted into the HTML view in RadEditor, with ConvertToXhtml turned off, then the browser will insert a BR tag into the empty table cell, in other browsers, this doesn't happen.

<table> 
    <tbody> 
        <tr> 
            <td></td
        </tr> 
    </tbody> 
</table> 
 
 

gets converted to:

<table> 
    <tbody> 
        <tr> 
            <td><br
            </td> 
        </tr> 
    </tbody> 
</table> 

If ConvertToXhtml is turned on, then this does not happen because the editor's filter validates the content.
However, if you need to disable this filter you can fix the problem with the custom content filter below:

SOLUTION
To fix the problem try the custom content filter below which will replace the <br> tag in the empty cell with &nbsp;
<telerik:RadEditor ID="RadEditor1" runat="server" OnClientLoad="OnClientLoad"></telerik:RadEditor>  
<script type="text/javascript">  
function OnClientLoad(editor, args)  
{  
   editor.get_filtersManager().add(new MyFilter());  
}  
    
MyFilter = function()  
{  
   MyFilter.initializeBase(this);  
   this.set_isDom(true);  
   this.set_enabled(true);  
   this.set_name("RadEditor filter");  
   this.set_description("RadEditor filter description");  
}  
MyFilter.prototype =  
{  
   getHtmlContent : function(content)  
   {  
             
           var cells = content.getElementsByTagName("TD"); 
              
           for (var i = 0; i < cells.length; i++) 
           
               var cell = cells[i]; 
                  
               if (cell.innerHTML == "<br>")   
               
                    cell.innerHTML = " "
               
           
          
       return content;  
   }  
}  
MyFilter.registerClass('MyFilter', Telerik.Web.UI.Editor.Filter);  
</script>
 

Comments

There are no comments yet.
If you'd like to comment on this KB article, please, send us a Support Ticket.
Thank you!

Please Sign In to rate this article.