Reply to Re: Servers side JavaScript detection in PHP4

Your name:

Reply:


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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация