0

このjsコードの最後の行は、別の関数に入れてhtml入力で実行しない限り実行されません。

function baseSize() {
    var available = window.screen.availHeight;

    var windowHeight = window.screen.height;
    var makeHeight = 849 - windowHeight;
    document.body.style.backgroundPosition = "0px -" + makeHeight + "px";

    var container = document.getElementById("container");
    container.style.height = available + "px";

    var right = document.getElementById("right");
    right.style.height = available - 230 + "px";

    var left = document.getElementById("left");
    left.style.height = available - 230 + "px";

    var storyright = document.getElementById("storyright");
    storyright.style.height = available - 40 + "px";
}

これはなぜですか?どうすれば修正/回避できますか? (そして、おそらく雑然としていることはわかっているので、締める方法を提案しないでください。それについては後で説明します。)

ここにhtmlがあります

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<link rel="stylesheet" type="text/css" href="stories.css" />
<script type = "text/javascript" src="script.js">
</script>
    <div id = "container">
    <body onLoad = "baseSize(); storySize();">
    <div id = "head">
        <table class="links">
        <tr>
        <td class="link"><a href="index.html">Home</a></td>
        <td class="link"><a href="poetry.html">Poetry</a></td>
        <td class="link"><a href="essays.html">Essays</a></td>
        <td class="link"><a href="stories.html">Stories</a></td>
        <td class="about"><a href="about.html">About</a></td>
        </tr>
        </table>
        <div id = "icon"><p>Craig InTheDell</p></div>
    </div>
    <div id="container2">
    <div id="top">
        <table>
        <tr>
        <td class="button"><input type="image" src="mostrecentbutton.jpg" onClick="showContent1()"/></td>
        <td class="button"></td>
        <td class="button"></td>
        <td></td>
        </tr>
        </table>

    </div>
    <div id="storyright">
        <div id="content1">
        <input type = "button" Value = "click me!" onClick = "storySize()"/>
        </div>
    </div>
    </div>
    </body>
    </div>
</html>
4

1 に答える 1