2011-01-01 4 views
2

iframe에서 호스팅되는 웹 페이지가 있습니다. 이 페이지 만 수정하고 포함 페이지는 수정할 수 없습니다.Firefox iframe 스크롤 문제

기본적으로 내 페이지의 스크롤바는 사용할 수 없지만 내 페이지 크기가 특정 임계 값을 초과하면 세로 스크롤 막대를 사용하도록 설정해야합니다. 다음 코드는 모든 브라우저하지만, 파이어 폭스에서 작동하는 것 같다 :

<html xmlns="http://www.w3.org/1999/xhtml" > 
    <head><title>My title</title></head> 
    <body id="pageBody" onload="setScrollbar();"> 
    </body> 
</html> 

파이어 폭스가 style.overflow의 = '스크롤'을 무시하고있는 것 같다 :

function getDocHeight() { 
    var D = document; 
    return Math.max(
     Math.max(D.body.scrollHeight, D.documentElement.scrollHeight), 
     Math.max(D.body.offsetHeight, D.documentElement.offsetHeight), 
     Math.max(D.body.clientHeight, D.documentElement.clientHeight) 
    ); 
} 

function setScrollbar() { 
    if (getDocHeight() > 5000) { 
     pageBody.style.overflow = 'scroll'; 
    } 
} 

여기 내 HTML입니다. 좋은 검색을 해봤는데 해결책을 찾을 수없는 것 같습니다. 어떤 아이디어?

답변

0

이 교체 :이와

pageBody.style.overflow = 'scroll'; 

을 :

내가 JS 오류 pageBody이 정의되어지고 있다고 FF에서 코드를 확인했습니다
document.getElementById('pageBody').style.overflow = 'scroll'; 

, 즉 문제를 해결해야합니다 :)

건배

G.

,
0

style.overflow = 'auto'이 더 잘 작동합니다. 스크롤바 자체를 언제 추가할지 브라우저가 결정합니다.

0

불행히도 Firefox는 몸체가 아닌 프레임의 오버플로 스타일을 기반으로 프레임 본문에 스크롤 막대를 표시합니다. 따라서 가장 쉬운 방법은 100 % 크기의 여백없는 스크롤 가능한 서브 프레임을 삽입하고 대신 실제 콘텐츠를로드하는 것입니다.

당신이 그렇게하지 않으려면, 다음과 같이 중첩 된 DIV에 어지 할 수 있습니다

<body style="margin: 0px;"> <!-- override default body margin --> 
    <div style="height: 100%; overflow: auto;"> <!-- The actual scrollable area --> 
    <div style="margin: 8px;"> <!-- to emulate default body margin --> 
     <!-- Content goes here --> 
    </div> 
    </div> 
</body>