Or you could use PHP
However, you may want to consider that blocking other browsers is a throw back to those users who claim you should get a real web browser and that the person trying to view may not be in a position to install chrome or have the technical ability to do so.
Restricting user access to a single type of browser is a virtual version of cutting your nose off to spite your face.
You should also know that if JavaScript is not present like some browsers out in the WWW do not have javascript or understand javascript (yes they do exist) or even turned off would mean that your blocking script would fail.