如果禁用javascript,则重定向到另一个页面

Sha*_*hah 14 javascript asp.net

我有很多功能通过javascript实现,如果在任何阶段javascript被禁用,他应该被重定向到另一个页面.提到他启用javascript然后继续.这个功能应该是跨浏览器兼容的,请注意,

Roh*_*til 21

使用<noscript>标签检查是否启用了JavaScript.<meta HTTP-EQUIV="REFRESH" content="0; url=http://www.google.com/">将它重定向到指定的url.Here在此示例中它将重定向到谷歌.

这是一个例子.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>How To Detect If User Javascript Is Enabled</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <style type="text/css">
    <!--
    .style1 {
    color: #FF0000;
    font-weight: bold;
    }
    -->
    </style>
    </head>
    <body>
    <p>The Purpose of this script is to show if you have javascript enabled in your browser.</p>
    <p class="style1">
    <script type="text/javascript">
    document.write('Javascript is enabled');
    </script>
    <noscript>
    Javascript is disabled.
    <meta HTTP-EQUIV="REFRESH" content="0; url=http://www.google.com/"> 
     </noscript>
    </p>
  </p>
    </body>
    </html>
Run Code Online (Sandbox Code Playgroud)


Bas*_*ter 9

从noscript块执行http重定向.喜欢:

<noscript>
    <meta HTTP-EQUIV="REFRESH" content="0; url=http://www.yourdomain.com/index.html"> 
</noscript>
Run Code Online (Sandbox Code Playgroud)