2012-09-09 3 views
0

iframe이 있고 실제 콘텐츠를 기반으로 크기를 조정하려고합니다 (예 : 스크롤하지 않도록). 나는 다음을 시도했다 :Firefox : 실제 콘텐츠에 따라 iframe의 크기를 조절하십시오.

alert (document.getElementById (iframe) .content); 경고 (document.getElementById (iframe) .contentWindow.document.body.scrollHeight); alert (document.getElementById (iframe) .contentWindow.document.body.offsetHeight);

해당 작업 없음. iframe에는 iframe의 ID가 들어 있습니다. 마지막 두 줄은 Chrome에서 작동합니다.

도움이 될 것입니다.

+0

두 도메인이 같은 도메인에 있습니까? – tomsv

+0

Yeap - same one – Yannis

+0

이 질문은 중복 되었습니까? http://stackoverflow.com/questions/11806947/is-it-possible-that-iframe-resize-itself-without-help-from-main-window – Juffy

답변

0

외부 문서에서 iframe의 문서 속성에 액세스 할 수는 없지만 다른 방법으로 수행 할 수 있다고 생각합니다. 해당 문서 내에서 iframe의 문서 속성에 액세스 한 다음 기능을 제공합니다. 이 외부 함수는 여기에 설명 된대로 크기 조정을 수행합니다. Resize iframe height according to content height in it

+0

분명히 어떻게 든 작동합니다. 그것은 크롬에서 잘 작동합니다 ... – Yannis

+0

Firefox에서 작동합니까? – tomsv

+0

내가 테스트 한 사람들은 아니지만 나는 두려워합니다. – Yannis

관련 문제