Is it possible to do checking and verification of JavaScript state in a browser ?
+1
A:
Is there any reason you need to do this via PHP, instead of displaying a message in the browser using the NOSCRIPT tag?
Justin Ethier
2010-08-27 21:10:25
yes, i need them to be one of basic condition how to display template and its feature. All html code that will be include into a php page (for example, index.php) based on the state of javascript
justjoe
2010-08-27 21:16:28
+3
A:
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.
cpharmston
2010-08-27 21:23:00
More on that subject: http://icant.co.uk/articles/pragmatic-progressive-enhancement/#build
David Dorward
2010-08-27 21:24:18
+1
A:
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.
eclipse31
2010-08-27 21:29:32