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.

有帮助吗?

解决方案

You can insert the tag

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

其他提示

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top