NYCPHP Meetup

NYPHP.org

[nycphp-talk] detecting Java Script from within a PHP script.

csnyder chsnyder at gmail.com
Fri Nov 16 09:20:53 EST 2007


On 11/16/07, Urb LeJeune <urb at e-government.com> wrote:

>         It there a way to detect if a user's browser has Java Script enabled
> from within a PHP script?

This might work:

<script type="text/javascript">
if ( !window.location.search ) {
  window.location = window.location.href+"?js=1";
}
</script>

Look for $_GET['js'] in your script. Note the conditional, which won't
check for js if there are any get vars.

Not tested in an actual browser, so ymmv. I bet setting a cookie value
would be more reliable...



More information about the talk mailing list