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,151
  • 5
  • 22
  • 41

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
  • 395,085
  • 80
  • 655
  • 663
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
  • 51,409
  • 25
  • 133
  • 214