从HTML iframe获取JSON文本 [英] Get JSON text from HTML iframe
问题描述
我想将表单提交到iframe并获得结果。结果必须是javascript可以理解的文本,所以我认为JSON是最好的主意。
我知道如何在javascript上获取iframe对象,但是我对如何获得内容没有理想。我的iframe的内容是只有JSON,我怎么才能检索它与JavaScript?
解决方案您可以通过JavaScript进行通信。 p>
可以使用iframe中的父属性来访问父窗口:
来自iframe的
window.parent.SomeFunctionDefinedInTheParent(JSONObject);
I want to submit a form into an iframe and get the result. The result has to be a text that javascript can understand, so I think that JSON is the best idea.
I know how to get the iframe object on javascript, but I have no ideia on how to get the content. The content of my iframe is only JSON, how can I retrieve it with javascript?
You can communicate via JavaScript.
The parent window can be reached using the parent property inside the iframe:
From the iframe do
window.parent.SomeFunctionDefinedInTheParent(JSONObject);
这篇关于从HTML iframe获取JSON文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!