質問

思い iframe く垂直スペースで表示の内容と表示されない、スクロールバーです。できれいに分かれているようです。

ありますか回避策の?

役に立ちましたか?

解決

この設定をしなければな IFRAME 高さはそのコンテンツの高さ:

<script type="text/javascript">
the_height = document.getElementById('the_iframe').contentWindow.document.body.scrollHeight;
document.getElementById('the_iframe').height = the_height;
</script>

を加えたいということ scrolling="no"IFRAME をオフにしてスクロールバー.

編集: マ忘れを宣言する the_height.

他のヒント

の回避策は使用しない <iframe> および前処理コードをサーバ側です。

このCSSスニペットはできるだけ除去することが望の垂直スクロールバー:

body {
  overflow-x: hidden;
  overflow-y: hidden;
} 

なんなのかなつかしい垂直スペースとして必要なんだんです。

を追加する DOCTYPE 宣言 IFRAME ソースドキュメントを計算し、正しい値から線

document.getElementById('the_iframe').contentWindow.document.body.scrollHeight

W3C DOCTYPE例

しかし問題は、両家のFFでのレンダリング iframe 文書の"癖'モードまでを加えた DOCTYPE.

FF/IE/クローム対応:きます。scrollHeightのだが、仕事Chromeいてjavascriptを使用jQueryを設定する IFRAME ハイツのページのiframesます。注意:こちらは参照ページ内の現在の領域です。

<script type="text/javascript">
    $(document).ready(function(){
        $('iframe').each(function(){
            var context = $(this);
            context.load(function(event){ // attach the onload event to the iframe  
                var body = $(this.contentWindow.document).find('body');
                if (body.length > 0 && $(body).find('*').length > 0) { // check if iframe has contents
                    context.height($(body.get(0)).height() + 20);
                } else {
                    context.hide(); // hide iframes with no contents
                }
            });
        });
    });
</script>
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top