在JavaScript中解析iframe的XML(AJAX技巧?) [英] Parsing iframe's XML in JavaScript (AJAX trick?)

查看:79
本文介绍了在JavaScript中解析iframe的XML(AJAX技巧?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于XMLHTTP请求不支持从其他

服务器加载XML,我决定使用一个技巧:

将XML加载到隐藏的iframe中然后获取该XML JavaScript to

解析。

但是,这是一个好主意吗?我被卡住了。如何在

iframe中加载XML并将其传递给JS函数进行解析?

谢谢。

Since XMLHTTP Request does not support loading of XML from other
servers, I decided to use a trick:
load XML into hidden iframe and then get that XML with JavaScript to
parse.
But, is this a good idea? I am stuck. How do I get XML loaded in the
iframe and pass it on to JS function for parsing?
Thank you.

推荐答案



vu ****** @ gmail .com 写道:


vu******@gmail.com wrote:

由于XMLHTTP请求不支持从其他

服务器加载XML,我决定使用技巧:

将XML加载到隐藏的iframe中,然后使用JavaScript获取该XML来解析。

但是,这是个好主意吗?
Since XMLHTTP Request does not support loading of XML from other
servers, I decided to use a trick:
load XML into hidden iframe and then get that XML with JavaScript to
parse.
But, is this a good idea?



您可以在(i)框架中加载XML但是脚本无法访问DOM

然后作为相同的原始策略也适用于该方法,因此如果iframe包含来自

不同来源的文档,则

获取访问权限或权限被拒绝。


-


Martin Honnen
http ://JavaScript.FAQTs.com/


Google RSS Feed如何运作?他们必须有一些解决方法,不是吗?


无论哪种方式我发现这是一个解决方法到目前为止,但我现在通过

测试它:


如何使用IFRAME将HTML文档解析为DOM: http://youngpup.net/userscripts/html...xample.user.js

How do Google RSS feed work? They must have some workaround, dont they?

Either way I found this to be a workaround so far, but I test it by
now:

example of how to use an IFRAME to parse an HTML document into a DOM:
http://youngpup.net/userscripts/html...xample.user.js



vu******@gmail.com 写道:



vu******@gmail.com wrote:


无论哪种方式,我发现这是一个解决方法到目前为止,但我现在用

进行测试:


如何使用IFRAME将HTML文档解析为DOM的示例:
http://youngpup.net/userscripts/html...xample.user.js



这是一个用户脚本或Greasemonkey脚本你必须安装fi rst。

如果用户安装了这样的脚本,那么它不会受到适用于文档中脚本的相同

原始策略(例如HTML或SVG
在浏览器窗口中加载
文件。

-


Martin Honnen
http://JavaScript.FAQTs.com/


这篇关于在JavaScript中解析iframe的XML(AJAX技巧?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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