1

私はインターネット全体を検索し、狂ったようにスタックオーバーフローを実行し、問題の半分を解決しました。リンクをクリックしてページのフルサイズを読み込むときにiframeのサイズを設定しようとしていますが、IEで動作するようになりましたしかし、FFでは何も起こりません。同じ高さを維持するだけです。

IEで機能するコード

function calcHeight() {
    var the_height = 0;
    //find the height of the internal page
    if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)) { //test for Firefox/x.x or Firefox x.x (ignoring remaining digits);
        the_height = document.getElementById('class').contentDocument.body.offsetHeight + 140;
    }
    else {
        the_height = document.getElementById('class').contentWindow.document.body.scrollHeight + 18;
    }
    document.getElementById('class').height = the_height + "px";
}

Iframeコード

    <iframe src="iframback.html" name="class" id`="class" width="100%" height="auto" scrolling="no" frameborder="0" onload="calcHeight();" allowtransparency='true'></iframe></td>

私はこれを理解することはできません!これは、「Ohio Conceal Handgun License(CHL)」をクリックして、その横にコードを表示し、IEの場合と同じようにIFRAMEを展開できると思われるテストページへのリンクです。ありがとう! http://www.dualactiontactics.com/Update/7/Training.html

4

1 に答える 1

0

iframeでidの代わりにid`を使用しています。最初にこれを変更してください

<iframe src="iframback.html" name="class" id`="class" width="100%" height="auto" 
scrolling="no" frameborder="0" onload="calcHeight();" allowtransparency='true'></iframe>

id`="class"から id="class"

とjsの変更ステートメントで

document.getElementById('class').height = the_height + "px";

document.getElementById('class').height = the_height;

また

document.getElementById('class').style.height= the_height + "px";
于 2012-11-12T04:42:32.387 に答える