【发布时间】:2016-07-30 00:48:34
【问题描述】:
我想知道是否有办法让 3 个 iframe 加载相同的资源 (http://myservice.php),而 iframe 只有一个请求。 myservice.php 返回一个 Html 文档,浏览器应该以某种方式加载 html 而无需重新加载所有内容 2 次,包括加载的 HTML 文档中的 CSS 和 JS。换句话说,是否可以仅从第一个 iframe 发送 1 个请求来从 myservice.php 加载 HTML 文档,而让其他 2 个 iframe 加载相同的 html 而无需发送额外的 http 请求。
<iframe id="iframe1" src="myservice.php"></iframe>//should send only request
<iframe id="iframe2" src="myservice.php"></iframe>//use the already loaded data without sending an additonal http request
<iframe id="iframe3" src="myservice.php"></iframe>
我曾考虑使用 jsonp 存储 html(以避免跨域问题)并将其存储在一个变量中,但我不确定它是否比使用多个 iframe 向我的 . php。此外,html 的大小也很重,我认为这会影响浏览器。
【问题讨论】:
标签: javascript html iframe cross-domain src