Changing the width of a Rich Text (HTML) Editor

Posted by Meryk on 01-Apr-2015 06:18

Hello,

I have a rich text area in the New/Edit  pages of an Object.

I am trying to change the width of this text area from script component (dynamically, depending on a field in a related object).

The problem is that this text area is an "iframe" in the DOM of that page, and I don't seem to be able to get to that iframe element, so I can change the width.

I have simply tried :

var iframe = document.getElementById('sectionContent_ifr');

But this keeps returning a null iframe.

I did some research, and it seems that iframes are not accessible from javascript due to some cross-domain issues, but my iframe here is the following :

<iframe id="sectionContent_ifr" src='javascript:""' frameborder="0" allowtransparency="true" title="Rich Text AreaPress ALT-F10 for toolbar. Press ALT-0 for help" style="width: 721px; height: 156px; display: block;"></iframe>

and I am not sure it is cross-domain.

Do you have any ideas how to do that please? 

Thank you

Meryem

Posted by Godfrey Sorita on 06-Apr-2015 15:40

Hi Meryem, 

You can adjust the width of textarea fields which uses Rich Text (HTML) Editor by using the code below:

<script>
$(function(){
  setTimeout( function() {setWYSIWYG_width("Description" ,500)}, 3000);
});

function setWYSIWYG_width (fieldName, widthInPixels){
  $("#rbi_F_"+ fieldName).find("div").eq(1).css("width", widthInPixels);
}
</script>

The WYSIWYG editor starts to render onload so a delay is needed to ensure the code is executed after the textarea renders.  

Regards,

Godfrey

All Replies

Posted by Godfrey Sorita on 06-Apr-2015 15:40

Hi Meryem, 

You can adjust the width of textarea fields which uses Rich Text (HTML) Editor by using the code below:

<script>
$(function(){
  setTimeout( function() {setWYSIWYG_width("Description" ,500)}, 3000);
});

function setWYSIWYG_width (fieldName, widthInPixels){
  $("#rbi_F_"+ fieldName).find("div").eq(1).css("width", widthInPixels);
}
</script>

The WYSIWYG editor starts to render onload so a delay is needed to ensure the code is executed after the textarea renders.  

Regards,

Godfrey

Posted by Meryk on 07-Apr-2015 03:28

Hi Godfrey,

Thank you for the reply. 'setTimeout' function was the solution I used finally and it's working properly.

Thanks :)

Mery

This thread is closed