Reputation: 32918
What would you do if your site visitors disabled JavaScript? Do you block them?
Upvotes: 5
Views: 1232
Reputation: 19960
Use the NoScript tag to say "Hey, Enable Javascript fool!"
<script type="text/javascript">
alert("Hello World!");
</script>
<noscript>
Hey, Enable Javascript fool!
</noscript>
(Please note that this is code is not ready deployment to your website. You can change the message to something more suitable than plain text.)
Upvotes: 3
Reputation: 6689
If your visitors didn't know they have JavaScript disabled, a simple message would let them know they should enable it.
<noscript>Please enable JavaScript in your browser</noscript>
Upvotes: 0
Reputation: 27315
For every site I build, I compare the cost of development for degrading gracefully, versus the loss of income by scaring off ~2-3% of the audience. Not caring about non-javascripters/Opera/etc usually wins...
Upvotes: 1
Reputation: 18539
To couple with <noscript>
I have all elements that require JS to function with class="js-required"
.
Then CSS: .js-required{display:none;}
JS on page load: $('.js-required').css('display','block')
Upvotes: 2
Reputation: 6139
Ideally, you would use progressive enhancement which entails guaranteeing a base user experience and then adding all the flourishes for browsers that can handle them.
Upvotes: 15
Reputation: 3011
you can check this out:
How to detect if JavaScript is disabled?
Upvotes: 0
Reputation: 22783
Indeed degrade gracefully. If that's not an option (anymore ;-)) then at least notify them with utilizing a <noscript>
tag.
Upvotes: 10
Reputation: 91816
Your website should be somewhat prepared if JavaScript is disabled, either display a message that your website works better with JavaScript enabled or work-around it.
Upvotes: 1