0

好的,这是 php.ini 生成的正文。

<body>
<div id="outerBox" name="outerBox">

<div id='topNav' name='topNav'>

</div>

Content

<div id='footer' name='footer'>
Footer
</div>
</div>
<script type="text/javascript">centerbody();</script>
</body>

那么这里是centerbody函数

function centerbody(){
    var container = document.getElementById('outerBox');
    var pageWidth = window.innerWidth;
    container.style.marginLeft = '50px';
    container.style.marginRight = '50px';
}

为什么getElementById没有得到outerBox?我已经使用了很长时间,但我无法弄清楚。

4

1 回答 1

0

你有几个错别字。您的标题未关闭,您的元标记值也未关闭。这破坏了破坏 getElementById 的 DOM。

<meta name='keywords' content='Gatlinburg Cabins, Gatlinburg Chalets, Budget Gatlinburg Cabins, Discoung Gatlinburg Cabins, Discount Gatlinburg Chalets, Budget Gatlinburg Chalets, Pet Friendly Cabins, Pet Friendly Chalets, Smoky Mountain Cabins, Smoky Mountain Chalets' />
<title>Awesome Gatlinburg CabinsHome Page</title>
于 2013-02-22T22:35:50.417 回答