| 
	
 | 
 Posted by Justin Koivisto on 08/05/05 16:25 
Jean Pion wrote: 
 
> Is there somewhere, maybe $_SESSION vars?, where my PHP knows that  
> JavaScript is enabled on the clients webbrowser. 
> I uses some JavaScript but would like to add workaround in case the browser  
> doesn't. Suggestions would be appreceated. 
 
After reading the subject, I actually thought this was going to be about 
server side javascript... (Which does exist to you nay-sayers.) 
 
One quick solution that I have done before for detecting javascript on a 
client is in the document have something like: 
 
<?php 
    if(!isset($_GET['js']) && !isset($_SESSION['js'])){ 
        $js=<<< eos 
            <script type="text/javascript"> 
                window.location.href='{$_SERVER['REQUEST_URI']}?js=1'; 
            </script> 
eos; 
    }else{ 
        $_SESSION['js']=1; 
        $js=''; 
    } 
?> 
<html> 
<head> 
<title>Javascript test</title> 
<?php echo $js ?> 
</head> 
<body> 
Javascript has <?php if(!empty($js)){ echo '<b>not</b>'; } ?> been 
detected on the client. 
</body> 
</html> 
 
Of course, if the REQUEST_URI already contains a query string, you'd 
want to append the js var instead of how I have it above, but it 
illustrates the method anyway. 
 
--  
Justin Koivisto, ZCE - justin@koivi.com 
http://koivi.com
 
  
Navigation:
[Reply to this message] 
 |