Reputation: 5564
Is it possible to do checking and verification of JavaScript state in a browser ?
Upvotes: 2
Views: 1161
Reputation: 396
At the top of your index.php you could do something like
<script type="text/javascript">
window.location = '/index_with_js.php'
</script>
So, if the browser had JS enabled, it would be redirected to a special index page, which could in turn set a session variable, e.g. $_SESSION['has_js'] = true;
If the browser doesn't have JS enabled, the page won't be directed, so $_SESSION['has_js']
won't ever be set.
Upvotes: 1
Reputation:
That's the wrong way to do it. PHP should be outputting markup that works with JavaScript off, and you should be enhancing that markup with JavaScript. I suggest you read up on progressive enhancement.
Upvotes: 3
Reputation: 134197
Is there any reason you need to do this via PHP, instead of displaying a message in the browser using the NOSCRIPT tag?
Upvotes: 1