Hi all is there any possible to make a java script disabled message like 404 page not found
for java script disabled browsers by users.
-
2The [` – Simon M Sep 17 '13 at 11:13
-
You can either use the – Darren Crabb Sep 17 '13 at 11:14
-
Refer http://stackoverflow.com/questions/3262479/how-to-inform-if-javascript-is-disabled-in-the-browser – Vignesh Paramasivam Sep 17 '13 at 11:15
-
@DarrenCrabb Those with JS enabled wouldn't see anything wrapped in ` – André Dion Sep 17 '13 at 11:15
-
@AndréDion He's thinking of text outside of a ` – Simon M Sep 17 '13 at 11:17
5 Answers
If you mean that you literally want the web server to send back status code 404, exactly as though the resource had not been found, for a page requiring JavaScript, then you can't reasonably do that, no. The server doesn't know whether the browser supports JavaScript as of when it's processing the request.
You can include a message between <noscript>...</noscript>
tags that will be shown by browsers with JavaScript disabled, but that's not a 404.
You may also be able to do this:
<noscript>
<meta http-equiv="refresh" content="0; url=http://example.com/404.html">
</noscript>
...which would redirect non-JavaScript users to another page, which can be a 404. This is because the noscript
element is allowed to contain meta information.

- 2,931
- 2
- 22
- 37

- 1,031,962
- 187
- 1,923
- 1,875
Something like this?
<noscript>
<div class="js-error">Javascript disabled.</div>
</noscript>

- 11,224
- 4
- 40
- 66
<noscript>JavaScript is disabled.</noscript>
Another strategy (one that Modernizr uses) is to add a no-js
class to your <html>
tag (<html class="no-js">
) and then have some JS remove/replace that class on page load so that you may prefix selector statements in your stylesheet with a .no-js
selector for custom display options:
.js .warning { display: none; } /* assumes .no-js is replaced with .js for those with JS enabled */
<html class="no-js">
...
<div class="warning">JavaScript is disabled.</div>
...
</html>

- 21,269
- 7
- 56
- 60
You could "fake" it by including the html-code for something that looks like a 404 page inside a section.

- 131
- 6
<script>
//the script
</script>
<noscript>
Your browser does not support JavaScript
</noscript>

- 61
- 5