Ivo Stoykov wrote in [EMAIL PROTECTED]:">news:[EMAIL PROTECTED]:

> Hello again
> 
> earlier today I asked about detecting whether javascript is
> enabled on the visitor's browser (bellow are the question and
> answeres received). 

<html>
<head>
</head>
<body>
<script type="text/javascript">

jsImg = new Image()
jsImg.src = "js-yes.gif";

</script>
<noscript>
<img src="js-no.gif" width="0" height="0" alt="" />
</noscript>  
</body>
</html>


Your access logs for the images js-yes.gif, and js-no.gif will give 
you stats over js/no-js.

If you need something more sophisticated, you can replace js-yes.gif 
and js-no.gif with serverside scripts that add the results to a 
database.

I have a sample php-script that gives you some of that functionality 
without resorting to database:

[jsenabled.php]
<?php
  if ($js_=="y"){
        $file = "ay.txt";
  } else if ($js=="n"){
        $file = "an.txt";
  }
  $fp = fopen($file,"a");
  fwrite($fp,"1");
  fclose($fp);
  header("Content-type: image/gif");
  readfile("spacer.gif");
?>

I then modify the html/js code to look like this:

[somedocument.html]
<html>
<head>
</head>
<body>
<script type="text/javascript">

jsImg = new Image()
jsImg.src = "jsenabled.php?js=y";

</script>
<noscript>
<img src="jsenabled.php?js=n" width="0" height="0" alt="" />
</noscript>  
</body>
</html>

Please note that you'd want to purge the an.txt and ay.txt every once 
in a while.

-- 
Arve                 <URL:http://www.bersvendsen.com/>

                Newsere mot X-No-Archive
<URL:http://www.ibiblio.org/Dave/Dr-Fun/df9601/df960124.jpg>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to