Check if Javascript is enabled or disabled thru PHP

In normal practice we make website supporting Javascript only and we show error if Javascript is disabled, but in some cases we might need to run a website/page even if Javascript is disabled.

You might need to execute certain code in PHP if Javascript is disabled for the browser, in that case following code might be useful to you,

<?php if(!isset($_GET[''noscript''])) {?>
<meta http-equiv="refresh" content="0;"/>
<?php } ?>

Here tag is under a condition which checks if variable is getting any value or not, that’s just to prevent from making page to go in infinite loop if you are redirecting on the same page, If you are redirecting to some other page then its not necessary.

As you can see in the code, you have to declare tag into and it will redirect to, query string is must in url because that the only thing thru which you can know if its redirected or not.

Now as you have redirected the page so following code will help you to execute your code needed at the time of disabled Javascript,

if(isset($_GET[''noscript'']) && $_GET[''noscript''] == "true")
{ echo "Hello World, we are here because Javascript is disabled."; }