0

This is simple richtexteditor we are know. textarea is not included iframe. but i need to get content of iframe.

var textfield = $("#richTextField").html();     
var textfield = $("#myTextArea").html();
<textarea style="display: none" class="myTextArea" name="myTextArea" id="myTextArea" cols="100" rows="14"></textarea>
<iframe name="richTextField" class="richTextField" id="richTextField" onload="window.frames['richTextField'].document.designMode='on';" ></iframe>
  

but both, textarea and iframe value is empty. how can i get content from textarea or iframe. thanks for reading.

이승현
  • 81
  • 2
  • 9

2 Answers2

0

the iframe depends on if it's in the same domain or not. if it's a different domain you won't be able to pull content from it.

for the textarea use .val()

var textfield = $("#myTextArea").val();
  • val is how you do it. if it didn't work you did something else wrong. https://jsfiddle.net/4h51ofgq/ –  Mar 13 '16 at 02:29
0

I find it and solved. thanks a lot

function getFrameContents(){
   var iFrame =  document.getElementById('id_description_iframe');
   var iFrameBody;
   if ( iFrame.contentDocument ) 
   { // FF
     iFrameBody = iFrame.contentDocument.getElementsByTagName('body')[0];
   }
   else if ( iFrame.contentWindow ) 
   { // IE
     iFrameBody = iFrame.contentWindow.document.getElementsByTagName('body')[0];
   }
    alert(iFrameBody.innerHTML);
 }

from here

Community
  • 1
  • 1
이승현
  • 81
  • 2
  • 9