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

FF insert <div> IE insert <p>

1 Answer 89 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Marek Svrcina
Top achievements
Rank 1
Marek Svrcina asked on 03 Nov 2009, 09:48 AM
I have very simple problem
Firefox 3.5.4
  • HTML
row1<br />
row2
  • DESIGN
... row1 selecting and put align right
  • HTML
<div style="text-align: right;">row1<br />
</div>
row2

IE8
  • HTML
row1<br />
row2
  • DESIGN
... row1 selecting and put align right
  • HTML
<p style="text-align: right;">row1<br />
row2 </p>


IE8 put tag <p> for row1 & row2  WHY ????

1 Answer, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 05 Nov 2009, 01:13 PM
Hi Marek,

JustifyLeft, JustifyCenter and JustifyRight buttons of RadEditor execute the built-in browser's JustifyLeft, JustifyCenter and JustifyRight commands. The difference browser's apply different tags and this is not controlled by RadEditor.

If you do not like this behavior you can try to implement the requested functionality yourself by overriding the JustfyLeft and other Justify commands and using TextRanges:

 <script type="text/javascript"> 
function OnClientCommandExecuting(editor, args) 
   //The command name 
   var commandName = args.get_commandName();    
        
   if ("JustifyRight" == commandName) 
   { 
    if ($telerik.isIE) 
    { 
        alert("add your custom code with textRanges here") 
        args.set_cancel(true); 
    } 
   } 
</script> 
 
<telerik:radeditor runat="server" ID="RadEditor1" 
    OnClientCommandExecuting="OnClientCommandExecuting"> 
</telerik:radeditor> 

You can obtain a range object like this:
var range = editor.getSelection().getRange();

You can also manipulate the range - e.g. expand it, and change the selection.
You can learn more about the TextRange object here:
http://www.wrox.com/WileyCDA/Section/JavaScript-DOM-Ranges-Page-2.id-292302.html
http://www.quirksmode.org/dom/range_intro.html
http://msdn.microsoft.com/en-us/library/ms535872(VS.85).aspx

Best regards,
Rumen
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Editor
Asked by
Marek Svrcina
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Share this question
or