1
콘텐츠를 기준으로 iFrame의 크기를 조정하는 것만 큼 문제가 있습니다. 나는 다른 곳에서 일하고 있지만이 한 예에서는 오류가 발생합니다. 다음 코드를 사용하면 body
이 null이므로 scrollHeight
을 얻을 수 없습니다.contentWindow.document.body is null
if(document.getElementById('iFrameHelpDesk') != null)
{
var Height = document.getElementById('iFrameHelpDesk').contentWindow.document.body.scrollHeight;
document.getElementById('iFrameHelpDesk').height = Height + 40;
}
사용되는 HTML은 다음과 같습니다
<iframe src="http://<snipped webaddress>" id="iFrameHelpDesk" scrolling="no" frameborder="no"></iframe>
가 왜이 body
객체의 이식하지 않는 이유는 무엇입니까?
iframe의 기본 페이지와 다른 도메인이 있으면 보안상의 이유로 iframe에 액세스 할 수 없습니다. – grc
@ grc - 페이지가 동일한 도메인에 있으므로이 문제가 없습니다. – anothershrubery
위의 요점 외에도, 위의 코드는 내가 지정한 다른 모든 iframe에도 적용됩니다. 문제를 일으키는 것은 바로이 것입니다. – anothershrubery