Shouldn't we use

前端 未结 11 928
北荒
北荒 2020-12-07 09:08

I found some good cons here:

  • The noscript element only detects whether the browser has JavaScript enabled or not. If JavaScript is disabled in the Firewall

相关标签:
11条回答
  • 2020-12-07 09:08

    I create a full height, full width, position:fixed div in all pages with some id .

    <div id='noscript_div' style='position:fixed;z-index:20000000;height:100%;width:100%;line-height:100%;'>enable JS buddy</div>
    $('#noscript_div').hide();
    $(document).ready(function(event){
    
    
    
    
    });
    

    I am not an expert . This worked for me . I am sorry but, this case will suit only if you want the user to have his javascript enabled always

    0 讨论(0)
  • 2020-12-07 09:15

    Although Tor Valamo has an elegant answer to this problem, there is an issue which may cause you to opt out of using this technique.

    The problem is (usually) IE. It has the tendency to load and execute the JS a bit slower than other browsers causing it to sometimes flash the "Please Enable Your Javascript" div for a split second before it then loads the JS and hides the div.

    It is annoying and to get around this you can implement the "classic". <noscript> redirect approach.

    <head>
    <noscript><meta http-equiv="refresh" content="0; URL=/NO_SCRIPT_URL/ROUTE_HERE"/></noscript>
    </head>
    

    This is the most solid technique that I've come across with regards to this little nasty.

    0 讨论(0)
  • 2020-12-07 09:19

    One useful application for noscript that I've seen is for a progressively-enhanced async loading of heavy content (especially "below the fold"). Big images, iframes, etc. can be wrapped in noscript in the HTML source, and then the unwrapped elements can be appended to the page using JavaScript after the DOM is ready. This unblocks the page and can make for a much quicker initial loading experience, especially if your interface relies on JS/JQ interactions applied after the document is ready (2 seconds vs. 6 seconds for a portfolio page I consulted on).

    0 讨论(0)
  • 2020-12-07 09:22

    It's better to have the default be non-javascript, and then let a javascript code overwrite with a javascript enabled page. Doesn't have to be much. Can just be a display:none; block, which is then set to display:block; by javascript, and vice versa for the non-js page.

    0 讨论(0)
  • 2020-12-07 09:25

    I recommend you not to use <noscript> , you can use the following code:

    <HTML>
    <head>
    <script>
         window.location="some-page.php";
    </script>
    </head>
    <body>
    <p>
        Please active JavaScript .
    </p>
    </body>
    </HTML>
    

    if under any circumstance JS is not enabled , the message will be displayed otherwise user is redirected to the destination page .

    0 讨论(0)
  • 2020-12-07 09:26

    Like all things, use the right tool for the job.

    If you are using Google Maps API, you have a static image via tag and that gets replaced with dynamic JS map. Google have recently started charging for everything thus with the above example it's going to cost you twice, once for static and once for dynamic. The static map is only relevant if JS is disabled. Therefore to save double paying it seems to me the best solution is to wrap the tag for the static map in a tag.

    0 讨论(0)
提交回复
热议问题