显示禁用JavaScript的浏览器的脚本的最佳做法

时间:2012-11-07 01:42:16

标签: html css

我正在开发一个仅适用于支持JavaScript的浏览器的网站。向非JavaScript浏览器提供警告的最佳方法是什么?显然需要使用<noscript>,但我会更加欣赏一些细节。我在想类似下面这样的东西,但它不起作用,甚至都没有验证。有什么想法吗?感谢

<!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">
    <body class="wrap">
        <noscript>
            <h1>JavaScript is turned off in your web browser.<br />Turn it on to use this site, then refresh the page.</h1>
            <style type="text/css">
                body { display:none; }
                noscript { display:block !important; }
            </style>
        </noscript>
        HTML for JavaScript browsers goes here...
    </body>
</html>

1 个答案:

答案 0 :(得分:0)

尝试禁用javascript,然后重新加载Stackoverflow。这是一个很好的干净方式,要求用户启用javascript。

然后尽可能地渲染网站。不要担心为禁用javascript的浏览器隐藏页面内容。

相关问题