1

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.

  • 2
    The [` – 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 Answers5

2

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.

Simon M
  • 2,931
  • 2
  • 22
  • 37
T.J. Crowder
  • 1,031,962
  • 187
  • 1,923
  • 1,875
1

Something like this?

<noscript>
    <div class="js-error">Javascript disabled.</div>
</noscript>
letiagoalves
  • 11,224
  • 4
  • 40
  • 66
1
<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>
André Dion
  • 21,269
  • 7
  • 56
  • 60
0

You could "fake" it by including the html-code for something that looks like a 404 page inside a section.

kruemi
  • 131
  • 6
0
<script>
//the script
</script>

<noscript>
Your browser does not support JavaScript
</noscript>