2013-09-20 02:16



I want to stop rendering the page and exit when the user's browser doesn't have JavaScript enabled or support, I want it like how exit() works in PHP. Is it possible via HTML?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答


  • douliao7930 douliao7930 8年前

    You can do this:

        <style type="text/css">body { display: none; } </style>
        <meta http-equiv="refresh" content="0; url=http://redirectpage.com/">
    点赞 评论 复制链接分享
  • dongzhuo3059 dongzhuo3059 8年前

    I think it's better to use ThiefMaster's and Dagon's concept together, as fallback support

    点赞 评论 复制链接分享
  • dongyuan1902 dongyuan1902 8年前

    Here's how you use the noscript tag:

    <!DOCTYPE html>
            <script type="text/javascript" >
            //  [whatever JS is appropriate]
                  <!-- Browser doesn't support JavaScript, so go elsewhere -->
                  <meta http-equiv="refresh" content="0;url=http://some.other-website.com/"> 
            .... The rest of the HTML body

    This only works in the <head> section with HTML5.

    点赞 评论 复制链接分享
  • doukuizuo1795 doukuizuo1795 8年前

    technically wrong but there is some browser support.

          <meta http-equiv="refresh" content="0;url=noscript.html">
    点赞 评论 复制链接分享
  • doushi5024 doushi5024 8年前

    No, that's not possible. What you could do, however, is add a stylesheet blanking out the page inside a <noscript> tag:

    * { display: none; }

    Of course that would hide everything; not just stuff that occurs later on the page.

    Another option that's very common is adding a no-js CSS class to the <body> tag which you remove as early as possible using JavaScript. That was you can properly create CSS rules to show/hide elements based on the (non-)existence of that class.

    点赞 评论 复制链接分享