Hi All,
how can i detect whether javascript is disabled using prototype library. I dont want to <noscript>
use tag but something that prototype offers.
Thanks
Hi All,
how can i detect whether javascript is disabled using prototype library. I dont want to <noscript>
use tag but something that prototype offers.
Thanks
Since Prototype is Javascirpt, you can not use it to detect wether Javascript is disabled or not. You have to use the <noscript>
tag.
Ummm if Javascript is disabled Prototype is never going to run my friend.
You can't detect that javascript is disabled using javascript. Google graceful degradation, and also progressive enhancement.
It would be pretty hard to use javascript to detect if javascript is disabled.
To answer your subquestion, if you want to emulate <noscript>
tag behavior without using noscript, make a <div>
element with the content you want to show to non-javascript users, and then hide it with javascript on DOMReady event. It will do exactly the same thing as a noscript tag.
<script type="Text/JavaScript">
document.observe("dom:loaded", function() {
$('simulate_noscript').hide();
});
</script>
<div id="simulate_noscript">
This is some content only users with JS disabled will see.
</div>
Prototype is a JavaScript framework. If JavaScript is disabled, Prototype will not run, making a JavaScript enabled check useless.
You will need to use a <noscript>
tag to handle situations where JavaScript is disabled.
You can't use JavaScript to determine if JavaScript is enabled; if it's not, then the script will never run. Instead, look to inject behaviours which require script using scripts themselves. This is a core principle of progressive enhancement.
Just thought I'd add to the myriad of comments already that question how you are to use javascript with javascript disabled. Make sure it degrades well of course.