如何根据其内容调整iframe的大小
这是我的HTML代码
<body>
<iframe id="test" src="http://www.bbc.co.uk/urdu/"></iframe>
</body>
这是我的jQuery代码
$(document).ready(function () {
setInterval(function () {
stretchHeight();
}, 5000);
function stretchHeight() {
$("#test").height($("#test").contents().find("html").height());
}
});
我没有间隔地尝试,但当时也没有工作
所以,请帮我
提前致谢
最佳答案
无法访问跨域的iframe中的html,因为这会带来安全风险。宽度和高度需要手动定义。
高温超导
关于jquery - 根据其内容高度调整iframe的高度,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/20748212/