从IFRAME复制HTML内容转换成格(AJAX)? [英] Copy html content from iframe into div ( ajax )?

查看:133
本文介绍了从IFRAME复制HTML内容转换成格(AJAX)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我们假设我有我的浏览器加载使用&其中一个IFRAME,IFRAME SRC =test.html的>

Lets assume I have my browser load an Iframe with <iframe src="test.html">

我可以使用AJAX,加载test.html中的内容到主HTML页面中的DIV?

Can I, using ajax, load the content of test.html into a div in the main html page?

这想法是我为事实,我其实是想克服使得AJAX提交到远程主机的限制的解决方案。该计划是与0大小的iframe,这使得报告请求到远程主机生成动态页面。然后,该页面(安培; iframe的内容)加载后我会复制iframe的内容转换成使用JS一个div。

This idea is my solution for that fact that I'm actually trying to overcome the limitation with making ajax submits to remote hosts. The plan is to generate the dynamic page with 0 sized iframe which makes report request to remote host. Then, after the page (& iframe content) loads I will copy the iframe content into a div using JS.

提示都是美联社preciated,

Tips are appreciated,

感谢您, 美心。

推荐答案

没有,你不能。

当您从另一个域中加载一个页面到iframe的,它变得无法访问。您无法再访问该iframe的内容,因为它来自不同的域。

When you load a page from a different domain into the iframe, it becomes unreachable. You can no longer access the contents of the iframe, as it comes from a different domain.

这是我所知道的,你可以可靠地从不同的域加载的唯一的事情是一个脚本,它的 JSONP 用途。

The only thing that I know of that you can reliably load from a different domain is a script, which JSONP uses.

这篇关于从IFRAME复制HTML内容转换成格(AJAX)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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