启用/禁用javascript时,页面无法在首次加载时正常显示

时间:2016-03-15 14:16:23

标签: javascript html twitter-bootstrap

这不是一个大问题,因为它似乎只是在更改设置和重新加载页面时发生,但它让我烦恼,因为我不明白为什么会发生这种情况。它在firefox上似乎没问题,但是Chrome有问题。

如果我禁用javascript然后刷新页面,它会打印<div class="alert alert-warning alert-dismissible fade in" role=alert>...stuff....</div>,但如果我第二次刷新页面,它会正确显示它。 关闭按钮有同样的问题,只是它反过来。

正常工作:
enter image description here

禁用JS并刷新(代码显示为文本):
enter image description here

刷新:
enter image description here

启用JS并刷新(无关闭选项):
enter image description here

刷新:
enter image description here

这是我的代码:

<head>
    <noscript>
        <style>
            #javascript_close{display:none;}
        </style>
    </noscript>
</head>

 <body>
    <noscript>
        <div class="alert alert-warning alert-dismissible fade in" role=alert>
            <h4>JavaScript is disabled!</h4>
            <p>stuff here.</p>
        </div>
    </noscript>

    <div class="alert alert-danger alert-dismissible fade in" role=alert>
        <button type=button class=close data-dismiss=alert aria-label=Close id="javascript_close">
            <span aria-hidden=true>&times;</span>
        </button>
        <h4>Sorry! We found a few problems!</h4>
        <p><span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span><span class="sr-only">Error:</span> Something is empty.</p>
        <p><span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span><span class="sr-only">Error:</span> Something else is invalid.</p>
    </div>
</body>

Here's the page如果有人想尝试的话(对源代码道歉,我用PHP生成它所以它缺少换行符)。这不是一个大问题,因为如果你不接触javascript设置似乎工作正常,但现在我知道它有点烦人,所以如果有快速的话修复任何人,我很感激

0 个答案:

没有答案