You are here: Re: How do I check if javascript is enabled in PHP? « All PHP « IT news, forums, messages
Re: How do I check if javascript is enabled in PHP?

Posted by NC on 10/11/30 11:59

Jim wrote:
>
> How do I check if javascript is enabled in PHP?

The temptation is to use get_browser() function, but it must be
resisted. get_browser() provides you with information about
what the browser CAN do. It cannot, however, tell you whether
the browser IS ALLOWED to do all it can. For example, many
browsers are capable of supporting JavaScript, but in many,
its support can be disabled.

So it's tricky. You can't do "it in one sitting"; you need to
output something (including some JavaScript), then see how the
client reacts to it. For example, this could be your index.php:

<html>
<head>
<script language="JavaScript">
window.location =
'http://www.yoursite.com/index1.php?js=1&token=<?php
echo time();
?>';
</script>
</head>
<body>
<p>Sorry, your browser does not support JavaScript...</p>
</body>
</html>

In index1.php, you check if $_GET['js'] is indeed 1 and if
$_GET['token'] is reasonably close to server's current time.

You will also need a mechanism to propagate this piece of
information...

Cheers,
NC

 

Navigation:

[Reply to this 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

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