我有这个代码:
var frames = document.getElementsByTagName("iFrame");
var auto_resize_timer = window.setInterval("autoresize_frames()", 400);
function autoresize_frames() {
for (var i = 0; i < frames.length; ++i) {
if (frames[i].contentWindow.document.body) {
var frames_size = frames[i].contentWindow.document.body.offsetHeight;
if (document.all && !window.opera) {
frames_size = frames[i].contentWindow.document.body.scrollHeight;
}
frames[i].style.height = frames_size + 'px';
}
}
}
那工作得很好。
然后,我决定把它放在自己的模块中:
function autoResizeFrames() {
var frames = document.getElementsByTagName("iFrame");
window.setInterval("autoresize_frames(frames)", 400);
}
function autoresize_frames(frames) {
for (var i = 0; i < frames.length; ++i) {
if (frames[i].contentWindow.document.body) {
var frames_size = frames[i].contentWindow.document.body.offsetHeight;
if (document.all && !window.opera) {
frames_size = frames[i].contentWindow.document.body.scrollHeight;
}
frames[i].style.height = frames_size + 'px';
}
}
}
并像这样在页面中运行它:
<script type="text/javascript">
$(document).ready
(
function () {
autoResizeFrames();
}
);
</script>
但是现在不行了?任何想法为什么?
谢谢