2010-09-21 65 views
2

Iam使用Tinymce编辑器创建一些内容。我使用textarea获取tinymce编辑器。在javascript中获取textarea值

对于edting我已经使用这个代码

<textarea id="page_content_id" name="page_content"><?php echo $page_content;?></textarea> 

所以保存的值将是微小的MCE editor.If我添加的东西给编辑我如何使用可以在javascript中的值

document.getElementById("page_content_id").value 

这不会给新的价值。如何我可以得到整个价值。

回答

6
<textarea id="page_content_id" name="page_content" cols="50" rows="15">This is some content that will be editable with TinyMCE.</textarea> 

<script language="javascript" type="text/javascript"> 
function ShowHTML(mceId) 
{ 
    alert(tinyMCE.get(mceId).getContent()); 
} 
</script> 

<input type="button" value="ShowHTML" onclick="ShowHTML('page_content_id');"> 

或使用​​

+0

感谢Oyeme.It在ie和firefox中工作 – Warrior 2010-09-21 07:23:52

2

您可以通过使用可以在javascript值以下

tinyMCE.activeEditor.getContent(); 

如果你有多个编辑器同时打开,使用