简体   繁体   English

从HTML iframe获取JSON文本

[英]Get JSON text from HTML iframe

I want to submit a form into an iframe and get the result. 我想将表单提交到iframe中并获取结果。 The result has to be a text that javascript can understand, so I think that JSON is the best idea. 结果必须是javascript可以理解的文本,因此我认为JSON是最好的主意。

I know how to get the iframe object on javascript, but I have no ideia on how to get the content. 我知道如何在javascript上获取iframe对象,但是我对如何获取内容没有任何想法。 The content of my iframe is only JSON, how can I retrieve it with javascript? 我的iframe的内容仅为JSON,如何使用javascript检索它?

You can communicate via JavaScript. 您可以通过JavaScript进行交流。

The parent window can be reached using the parent property inside the iframe: 可以使用iframe中的parent属性访问父窗口:

From the iframe do 从iframe做

window.parent.SomeFunctionDefinedInTheParent(JSONObject);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM