【问题标题】:Is this trick safe to do in all browsers?这个技巧在所有浏览器中都安全吗?
【发布时间】:2011-08-06 11:46:48
【问题描述】:

这在所有浏览器中都安全吗?这是一种在 js 关闭时简单地将用户重定向到不同位置的方法。

<noscript>
  <meta http-equiv="refresh" content="0;url=http://site.com/nojs">
</noscript

【问题讨论】:

标签: javascript graceful-degradation


【解决方案1】:

我更喜欢将no-js 类添加到&lt;html&gt; 元素。您可以将此技巧与ie-x 类结合使用。

例如:

<!doctype html>
<!--[if lt IE 7]> <html class="no-js ie6" lang="en"> <![endif]-->
<!--[if IE 7]>    <html class="no-js ie7" lang="en"> <![endif]-->
<!--[if IE 8]>    <html class="no-js ie8" lang="en"> <![endif]-->
<!--[if gt IE 8]><!-->  <html class="no-js" lang="en"> <!--<![endif]-->

<head>
<!-- some meta tags --->
<script>
(function(doc) {
   doc.className = doc.className.replace(/(^|\b)no\-js(\b|$)/, 'js');
}(document.documentElement));
</script>
<!-- other script tags should be before </body> -->

您可以在此处阅读:html5boilerplatehere

【讨论】:

    猜你喜欢
    • 2010-09-11
    • 2011-05-07
    • 2012-01-15
    • 2011-04-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-10
    • 2013-02-17
    相关资源
    最近更新 更多