views:

225

answers:

7

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

+5  A: 

Since Prototype is Javascirpt, you can not use it to detect wether Javascript is disabled or not. You have to use the <noscript> tag.

mikezter
ok guys thx...say i want to display some text when javascript is disabled is there any alternatate tag beside <noscript>
kjkjl
+1  A: 

Ummm if Javascript is disabled Prototype is never going to run my friend.

prodigitalson
you mean "disabled" ?
ram
@Ram: yes, yes i do... Corrected.
prodigitalson
ok guys thx...say i want to display some text when javascript is disabled is there any alternatate tag beside <noscript>
kjkjl
Well i suppose you could use something arbitrary like a div and then assuming js is enabled you could remove that div from the dom. If js werent enabled then it wouldnt be removed. But i dont see what your issue is with the noscript tag.
prodigitalson
+2  A: 

You can't detect that javascript is disabled using javascript. Google graceful degradation, and also progressive enhancement.

Kyle Butt
ok guys thx...say i want to display some text when javascript is disabled is there any alternatate tag beside <noscript>
kjkjl
+7  A: 

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>
code_burgar
ok guys thx...say i want to display some text when javascript is disabled is there any alternatate tag beside <noscript>
kjkjl
Edited my original answer to answer the subquestion.
code_burgar
your answer sounds good can you please elaborate with an example if you dont mind.
kjkjl
There you go :)
code_burgar
thanks buddy... it helps
kjkjl
You are welcome
code_burgar
+1  A: 

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.

Aaron
ok guys thx...say i want to display some text when javascript is disabled is there any alternatate tag beside <noscript>
kjkjl
This is exactly how you would display some text if JavaScript were disabled: `<noscript>You don't have JavaScript enabled.</noscript>`
Aaron
+2  A: 

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.

Rob
ok guys thx...say i want to display some text when javascript is disabled is there any alternatate tag beside <noscript>
kjkjl
A: 

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.

kalpaitch