Redirecting Browser to a page if JavaScript support is not there

If you have developed a page which depends on JavaScript for form validation or for any other purposes then you would be interested in detecting the setting of the client browser and would like to redirect to a different page explaining how to enable or disable JavaScript. Here we will discuss how to check this setting and redirect to a different page accordingly. We can detect this by using noscript tag and if the JavaScript is disabled then the code within this noscript tag will be executed. Here is the code to do that. This code will detect if the script setting is disabled and will redirect to a page explaining how to enable or disable JavaScript. This code will will also redirect the page with meta refresh in 2 seconds.

Demo of javaScript support and redirecting

Here is the code
<html>
<head>
<title>Demo of Checking if JavaScript is enabled in web browser</title>
</head>
<body >
<noscript>
<meta http-equiv="refresh" content="2; URL=enable_javascript.php">
Are you using a browser that doesn't support JavaScript?<br><br>

If your browser does not support JavaScript, you can upgrade to a newer browser<br><br>

If you have disabled JavaScript, you must re-enable JavaScript to use this page. To enable JavaScript:
</noscript>

<br><br>
If you are not seeing any message above this line then you have JavaScript enabled in your browser.
</body>
</html>
In the above code check this line
<meta http-equiv="refresh" content="2; URL=enable_javascript.php">
This line redirects the browser to a different page after 2 seconds. You can change the time duration by changing 2 seconds to any other value.
Subscribe to our YouTube Channel here


Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com




    Amirreza

    27-06-2014

    Perfect method!
    Used on my webiste,It fully works without any errors!
    soma

    02-08-2016

    meta tags can be disabled in some browsers.
    smo1234

    02-10-2016

    No, meta tags can't be disabled..

    Post your comments , suggestion , error , requirements etc here .




    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer