Javascript 未捕获类型错误:对象[Object global]没有方法';调整框架大小';
我正在按照教程(超过300票!)根据屏幕上内容的高度调整iframe的大小 我的问题是我得到了未捕获的TypeError:Object[Object global]在我的helper.html中没有“ResizeIframe”方法 想知道以前是否有人遵循过stackoverflow的答案,也遇到过这个问题 My helper.html:Javascript 未捕获类型错误:对象[Object global]没有方法';调整框架大小';,javascript,jquery,iframe,resize,Javascript,Jquery,Iframe,Resize,我正在按照教程(超过300票!)根据屏幕上内容的高度调整iframe的大小 我的问题是我得到了未捕获的TypeError:Object[Object global]在我的helper.html中没有“ResizeIframe”方法 想知道以前是否有人遵循过stackoverflow的答案,也遇到过这个问题 My helper.html: <html> <h1>Helper</h1> <!-- Testing small change. --> &
<html>
<h1>Helper</h1>
<!-- Testing small change. -->
<!--
This page is on the same domain as the parent, so can
communicate with it to order the iframe window resizing
to fit the content
-->
<body onload="parentIframeResize()">
<script>
// Tell the parent iframe what height the iframe needs to be
function parentIframeResize()
{
var height = getParam('height');
// This works as our parent's parent is on our domain..
parent.parent.resizeIframe(height);
}
// Helper function, parse param from request string
function getParam( name )
{
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^&#]*)";
var regex = new RegExp( regexS );
var results = regex.exec( window.location.href );
if( results == null )
return "";
else
return results[1];
}
</script>
同样,大部分代码来自stackoverflow帖子:。它真的应该是parent.parent吗?在iframe/frame中有一个iframe?这样更改
resizeIframe=function(height)
@epascarello是正确的。第一个iframe嵌入到页面上,它有一个“helper”“iframe,其高度可调整其高度。我没有遵循您引用的教程,但我的函数基本上做了相同的事情,并且在页面加载的1/3时间内,我会得到相同的错误。
function resizeIframe(height)
{
// "+60" is a general rule of thumb to allow for differences in
// IE & and FF height reporting, can be adjusted as required..
if (document.getElementById('embedded-iframe')) {
document.getElementById('embedded-iframe').height = parseInt(height,10)+60;
}
}