dsklfsdlkf1232
dsklfsdlkf1232
2013-09-20 02:16

有没有办法停止使用HTML渲染当前页面[关闭]

已采纳

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?

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

5条回答

  • douliao7930 douliao7930 8年前

    You can do this:

    <noscript>
        <style type="text/css">body { display: none; } </style>
        <meta http-equiv="refresh" content="0; url=http://redirectpage.com/">
    </noscript>
    
    点赞 评论 复制链接分享
  • 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>
    <html>
        <head>
    
            <script type="text/javascript" >
            //  [whatever JS is appropriate]
            </script>
            <noscript>
                  <!-- Browser doesn't support JavaScript, so go elsewhere -->
                  <meta http-equiv="refresh" content="0;url=http://some.other-website.com/"> 
            </noscript>
    
        </head>
        <body>
            .... The rest of the HTML body
    
        </body>
    </html>
    

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

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

    technically wrong but there is some browser support.

       <noscript>
          <meta http-equiv="refresh" content="0;url=noscript.html">
        </noscript>
    
    点赞 评论 复制链接分享
  • 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:

    <noscript>
    <style>
    * { display: none; }
    </style>
    </noscript>
    

    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.

    点赞 评论 复制链接分享