从HTML iframe获取JSON文本 [英] Get JSON text from HTML iframe

查看:594
本文介绍了从HTML iframe获取JSON文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将表单提交到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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆