【发布时间】:2014-03-31 22:58:10
【问题描述】:
我正在尝试将 iframe 高度参数更改为 iframe 中正在加载的页面的相同像素。在 iframe 中加载的页面来自另一个域。
不同的页面会加载到 iframe 中,导致 iframe 内容的高度发生变化,所以我需要抓取 iframe 内容高度并将其应用于 iframe 高度参数。
这是我在谈论的一个例子:http://jsfiddle.net/R7Yz9/3/
<div class="site"><a href="http://amazon.com/" target="_top">Amazon </a></div>
<div class="site"><a href="http://cnn.com/" target="_top">Cnn </a></div>
<div class="site"><a href="http://wikipedia.org/" target="_top">Wikipedia </a></div>
<iframe id="source" src="http://amazon.com/" frameborder="0" scrolling="no" width="100%" height="100%"></iframe>
.
$(document).ready(function() {
var iframe = $( "#source" );
$( "a[target=_top]" ).click( function(){
iframe.attr( "src", this.href );
return false;
});
});
【问题讨论】:
-
你能告诉我你能把任何代码放在容器页面还是你想把任何第三方页面放在你的 iframe src ..??
-
PellePenna:我希望在 php 或 jquery 中执行此操作
-
YashPatel:我希望能够将任何第三方页面放入 iframe
标签: javascript jquery html css iframe