How to redirect if JavaScript is not enabled in a browser?

JavascriptWeb DevelopmentFront End Technology

To redirect if JavaScript is not enabled in the web browser, add a script to the <noscript> tag. Let us say you need to redirect to index.php if JavaScript is not enabled. 

Example

Here’s how you can do this:

<!DOCTYPE html>
<html>
   <head>
      <title>HTML noscript Tag</title>
   </head>
   
   <body>
      <script>
         <!--
            document.write("Hello JavaScript!")
         -->
      </script>
     
      <noscript>
         <style>html{display:none;}</style>
         <meta http-equiv="refresh" content="0.0;url=nojs/index.php”>
   </body>
</html>

Above, we first use CSS style, since we do not want the actual page to be visible if JavaScript is disabled in the web browser.

raja
Published on 09-Feb-2018 05:51:02
Advertisements