0

ページロードの開始時に関数を実行する必要がありますが、単に機能しません。親 HTML (メインと呼ばれる) と 3 つのフレーム (子フレーム A、フレーム B、フレーム C) があります。

main.html:

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
    <script type="text/javascript" src="js/main.js"></script>
    <title></title>
    </head>
    <frameset cols="40%,*">
    <frameset rows="55%,45%">
            <frame src="frameA.html" name="frameA" id="frameA" />
            <frame src="frameB.html" name="frameB" id="frameB" />
        </frameset>
            <frame src="frameC.html" name="frameC" id="frameC" />
    </frameset>
    </html>

フレームA、B、C:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
    <title>FrameA</title>
    </head>
    <body>
    <h1>FRAME A</h1>
    </body>
    </html>

そしてmain.js:

    function resetC() {
        var oFrame = document.getElementById('frameC');
        oFrame.document.write("Frame C reseted");
    }
    resetC();

「oFrame is null」にうんざりしました。なぜそれが起こるのですか?

4

1 に答える 1