Chrome browser detection in HTML

How can I detect the Google Chrome browser? For example, I can detect Internet Explorer with this tag:

<!--[if lte IE]>
<link href="ie_only.css" rel="stylesheet" type="text/css" />
<![endif]-->

I have one idea:

var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;

But maybe someone has a better solution?

Update: My page does not display correctly only with the Chrome browser, so I need to download (only with chrome) a special css file with updates

+5
source share
2 answers

, , . , , WebKit CSS. , /, Chrome/Safari, :

@media screen and (-webkit-min-device-pixel-ratio:0) {
  /* Chrome- and Safari-specific CSS here*/
}

: - Chrome/Safari, Firefox, , , . . HTML- ( ) .

+19
var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
if (is_chrome) {
    document.write("Yaii it is Chrome only")
}

: " Chrome javascript"

+2

All Articles