I want to check if Javascript enabled or not.
If its enabled then it show the rest of code but if it’s disabled it will redirect to google.com
Now, how to do that? I’m trying to write this code:
<script type="text/javascript">
document.write("Hello World!")
</script>
<noscript>Your browser does not support JavaScript!
<p>JS must be enabled</p>
<META HTTP-EQUIV=Refresh CONTENT="3; URL='www.google.com'">
</noscript>
<p>this code must be hidden when JS is disabled</p>
but the result is:
Your browser does not support JavaScript!
JS must be enabled
this code must be hidden when JS is disabled
and what I want to is the code outside the noscript won’t run if there’s no JS enabled
so, at the example it would like this:
Your browser does not support JavaScript!
JS must be enabled
(go to google)
Info: I’m using PHP
I think your code is correct
please change
use http://
and for content hiding use a class for body and set its property to display none, and use a jquery function to add display block to show the content, the jquery function only works if javascript is enabled. so the content is disabled for javascript disabled mode.
eg.,