Question

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

below method working fine. However please let me know is it cross browsered and is it 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 anyother professional way I can do it.

PS: Some of my user tried to disable JavaScript after page load. This thing also affect some of my pages. I am getting wrong values on submit since the js disabled. I wanna overcome this situation please.

Was it helpful?

Solution

You can insert the tag

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

OTHER TIPS

Whilst the redirect certainly works the pages will still continue to load.

I have this problem and was hoping to find a solution. The answer is somewhere between the solutions so far offered:

<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 loading.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top