How to know and handle disabled javascript in browser
Posted on April 27, 2008
Filed Under how-to, javascript, tips and technique
In this blog, I’ve been writing a lot of tips and tutorials using JavaScript. I really love JavaScript and hope that you guyz also like it. But what to do when JavaScript is disabled in the client’s browser?. I would like to redirect the visitor to a warning page where he’ll be suggested to enable the JavaScript.
In many scenario, we must need JavaScript in some pages and we never want to process that page.In this post, I’ll show you how to know and handle the disabled JavaScript in browser.
First click on the below link to see a JavaScript enabled page. Now, disable the javaScript in browser and click the below link.
How to know JavaScript is disabled in browser?
As you guyz know, <script></script> tag is used for javaScript. Same way there is <noscript></noscript> tag which gets in action when the Javascript is diabled in browser.
<script>code here gets executed when javascript is enabled</script> <noscript>code here gets executed when javascript is diabled</noscript>
How to handle diabled javascript in browser?
When javascript is diabled I always want user to be redirected to a page to show warning to enabled javascript.But, JavaScript is diabled how to do this ? well there is meta tag in HTML named “meta refresh” which will redirect you to another page in the interval specified in that header
<noscript> <META HTTP-EQUIV="Refresh" CONTENT="0;URL=disabled.html"> </noscript>
As, you can see above code inside noscript, there is “meta refresh” tag with intevel of “0″ second. As, the javascipt is disabled in that page, the browser gets redirected to “disabled.html” to show some warning message
Popularity: 8% [?]
If you like this post then please subscribe to my full RSS feed . You can also subscribe by email and have new posts sent directly to your inbox.
Related Posts
» Jquery : Benefits, Examples and Free Ebook
» Why php is popular in the web
» Display random number in random way using JavaScript
» This blog’s Code and content is stolen - Please help
Comments
8 Responses to “How to know and handle disabled javascript in browser”
Leave a Reply




There is no good reason today to use the noscript tag. It may take a bit more thought up front but it is much better to use unobtrusive JavaScript techniques. For example, you can create a simple message in a unique tag (such as p) at the beginning of your markup indicating that JavaScript is required to get full use of your site/application. Then, all you need to do is $(”#uniqueId”).hide() the element using JavaScript, and you avoid the need for a redirect or other harsh punishment for disabling scripting.
jason..you are right and it would be better not to give punishment..but If you’ve a highly rich javascript application then you really don’t want to use the website to be browsed with disabled javascript…but If the page don’t have rich user interface then your solution is highly accepted..
I see both your points but I do believe what Roshan is saying, if your application rich enough there is no reason to keep them on that page.
Redirect them to a page letting them know your page is safe and let them know the benefits of enabling JavaScript.
what ashley said. javascript-intensive pages should redirect to a separate page for site visitors with javascript disabled. it doesn’t make sense to extensively code an application to allow visitors with javascript disabled to view the site when the majority of the intended functionality is disabled. wouldn’t viewing a disabled site (without being redirected) be a punishment in itself? what jason said — unobtrusively hiding page elements rather than redirecting visitors — would make more sense when applied to less javascript-heavy sites.
[...] Javascript ajax ile birlikte çok önem kazand?. Bir çok projede javascript kullan?yoruz, peki kullan?c?n?n taray?c?s?n?n javascript aç?k m? kapal? m? oldu?unu nas?l anlar?z. Ba?lant? [...]
by the way, noscript tag is not allowed in head tags. so if you are addicted to w3c standards and green html tidy tick in firefox, this usage would be problematic.
Ya Neru right…if you want your page to be validated from w3c please don’t use noscript tag inside head tag…
another addition
being curious, i just disabled javascripts and tried some websites like google reader, team vidget, script.aculo.us etc, there are 3 different solutions for these javascript disabled browsers,
1) use roshan’s solutions and redirect another page.
2) use jason’s suggestion and display a “javascript should be enabled” message
3) given up some navigation and content display effects and making site usable both javascript enabled and disabled cases.