Stop loading PHP page if javascript is not enabled

I am trying to stop loading my php page if javascript is not enabled on the user machine.

below method works fine. However, please let me know that it is cross browser and safe?

<noscript> <?php echo "Please Enable JavaScript in your browser!"; exit; ?> </noscript> <div id="main"> <!-- #header --> <div id="header"> <div id="logo"><a href="homepage.php" title="Go to Homepage"><span><?php echo $Name;?></span></a></div>..... 

Please let me know any professional way that I can do this.

PS: Some of my users tried to disable JavaScript after loading the page. This thing also affects some of my pages. I get the wrong values ​​to send as js is disabled. I want to overcome this situation, please.

+4
source share
2 answers

You can insert tag

 <title>Your title</title> <noscript><meta http-equiv="refresh" content="0; URL=/badbrowser.html"></noscript> 
+18
source

Although redirecting certainly works, pages will continue to load.

I have this problem and I hope to find a solution. The answer lies somewhere between the proposed solutions:

 <noscript> <meta http-equiv="refresh" content="0; URL=/badbrowser.html"> <?php exit; ?> </noscript> 

This starts the redirect, but also prevents the rest of the PHP page from loading.

0
source

Source: https://habr.com/ru/post/1468995/


All Articles