Possible Duplicate:
Check if JavaScript is enabled with PHP
I need a way to detect if javascript is enabled or disabled in the user-agent in the codeigniter framework
Possible Duplicate:
Check if JavaScript is enabled with PHP
I need a way to detect if javascript is enabled or disabled in the user-agent in the codeigniter framework
You cannot detect this directly on the server-side. Please take a look at this article for alternative solutions: http://www.untwistedvortex.com/detect-javascript-enabled-php/
You don't get this information with the HTTP-headers. But i have a little workaround:
You can store this information in the User-Session. By default you suggest, that JS is disabled. The first delivered Page should execute a Ajax-Call to a script which tells the USER-Session, that Javascript is enabled.
Of course this has some disadvantages:
Some times it is enough to have the information, if JS is enabled or not, in the CSS. You can do it like this:
<head>
<script type="text/javascript">
// Jquery version
$(function() {
$('body').removeClass('noJs');
});
</script>
<style type="text/css">
.noJs #hello {
display: none;
}
</style>
</head>
<body class="noJs">
<div id="hello">Hello</div>
</body>
There is no way to do a reliable detection in CodeIgniter or other framework/plain PHP.
Besides, that information is not part of the standard browser header/user-agent.