0

Can an htaccess could detect a browser if it's javascript enable or disabled and write a certain condition if javascript is disbled?

Like this

if(js)

DirectoryIndex ../locnfo/jsenable.php else

DirectoryIndex ../locnfo/jsdisable.php

spicykimchi
  • 1,155
  • 5
  • 22
  • 37

2 Answers2

2

No, an .htaccess file cannot do such a thing : an .htaccess file configures how Apache (server) behaves -- while Javascript is something that's on the client-side (browser).

If you want to detect whether Javascript is enabled or not, you'll have to do that on the client-side.
About that, here are a couple of questions / answers that might help :

Community
  • 1
  • 1
Pascal MARTIN
  • 385,748
  • 76
  • 642
  • 654
2

This has to be done on the client side, it cannot be detected elsewhere. The best thing I would suggest is to have something like

<script type="text/javascript">
   document.write('<script type="text/javascript" src="path/to/js"></script>');
</script>

so the file is only included if Javascript is enabled.

Yanick Rochon
  • 47,885
  • 24
  • 119
  • 191