Tip: Detectar Navegador Google Chrome con JavaScript

04-10-2008 Desarrollo Web, JavaScript 9289 hits (81.26 %) 4 comentarios

Una manera de saber si el navegador usado es Chrome mediante JavaScript:

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

Probando:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Chrome testing</title>
<script type="text/javascript">
function is_chrome(){
var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
alert(is_chrome);
}
</script>
</head>

<body onload="is_chrome()">
</body>
</html>

Chrome Test

Vía Code Purity

 

autor image Jesus Liñan
Programador de software, especializado en web sacando provecho de todos los recursos de la internet para el desarrollo y diseño web y compartiendolo con todos. Seguir @jesusvld

Advertisement

4 comentarios a "Tip: Detectar Navegador Google Chrome con JavaScript"

  1. GRACIAS
    tnkx from brazil =P
  2. Buen aporte. es muy util saber esto
  3. Gracias :)
  4. Grandioso, justo lo que necesitaba, buen aporte

Comentar