【发布时间】:2015-05-04 16:38:26
【问题描述】:
谁能帮我把这段代码在谷歌浏览器上运行? 它在 IE 上完美运行。
谢谢。
<!doctype html>
<html>
<head>
<script src="http://code.jquery.com/jquery-2.1.3.min.js"></script>
<script>
function calcIframeSize() {
var altura = $("body", $("#frameExtraFields").contents()).height();
$("#frameExtraFields").height(altura);
}
$(document).ready(function() {
$("#frameExtraFields").ready( function() {
calcIframeSize();
});
});
</script>
</head>
<body>
<iframe src="frame.html" width="80%" height="600" id="frameExtraFields"></iframe>
</body>
</html>
【问题讨论】:
-
预期结果是什么?
-
你的问题来自
$("#frameExtraFields").ready,并不代表iframe里面的文档被加载了。 -
我尝试将就绪事件更改为加载事件,但没有成功。仅在 Chrome 和 Firefox 中不起作用。在 IE 中它可以正常工作。
标签: javascript jquery google-chrome iframe