javascript - Tinymce get content -


i try content of tinymce, this:

 var hallo = tinymce.activeeditor.getcontent();             alert(hallo); 

but every time message:

uncaught typeerror: cannot read property 'getcontent' of null 

i using tinymce 4.

thank you

cannot read property 'getcontent' of null means tinymce unable find textbox means there wrong in reference textarea's class.

<form method="post" action="somepage">     <textarea id="mytextarea" class="mceeditor">i should buy boat. </textarea> </form>  <button onclick="content()">get content</button> 

take note of mceeditor class inform tinymce editor :

<script type="text/javascript">      tinymce.init({         mode : "specific_textareas",         editor_selector : "mceeditor"   //<<<----      });  </script> 

and contents of textbox on button click.

function content() {     alert(tinymce.get('mytextarea').getcontent()); } 

here working demo


Comments