在iframe中格式化文本时如何从iframe到textarea获取内容 [英] how to get content from iframe to textarea while formatiing text in iframe
本文介绍了在iframe中格式化文本时如何从iframe到textarea获取内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,我已经使用iframe开发了一种文本编辑器,可以在其中格式化粗体,斜体和下划线等文本.现在,我想将格式化后的文本放到我的文本区域,同时格式化旁边的文本我的iframe ...
请在此提示时帮助我...预先感谢..
Hi folks,I''ve developed a text editor using iframe which there i am formatting the text like bold,italic and underline..Now i wanted the formatted text to my text area while i formatting the text which is next to my iframe...
Please help me in this reagards...Thanks in advance..
推荐答案
您好,先生,
这很简单,但是您必须确保iframe内容页面(编辑器)和文本框页面(预览)在同一个域中.
1-在主页上创建一个Java脚本函数,以获取内容并将其放入文本字段
喜欢
函数fillText(text)
{
field = document.getElementById(''textFieldId'');
field.value =文本;
}
2-现在在编辑器窗口中处理事件(onkeypress)
可以说我们有一个全文编辑器的简单文本区域.
< textarea onkeypress ="parent.fillText(this.value)"></textarea>
希望这可以弄清楚:D
Hello Sir,
This is quite simple, but you must be sure that the iframe contents page(the editor) and your text box page(preview) are on the same domain.
1- Make a java script function in the main page which gets the content and puts it to the text field
like
function fillText(text)
{
field = document.getElementById(''textFieldId'');
field.value = text;
}
2- now handle the event (onkeypress) in the editor window
lets say we have a simple textarea insead of a full text editor
<textarea onkeypress="parent.fillText(this.value)"></textarea>
Hope this make things clear :D
这篇关于在iframe中格式化文本时如何从iframe到textarea获取内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文