A useful but often overrated JavaScript function is the browser detect. Sometimes you want to give specific instructions or load a new page in case the viewer uses, for instance, Safari.

If you're new to JavaScript, don't use browser detects. You don’t need them. Please read the object detection page first.

Use WhichBrowser

This page used to contain my own browser detect script, but I found that I do not have enough time to keep it up to date. Therefore I removed it.

I advise you to use WhichBrowser. It’s up-to-date, and contains a treasure trove of mobile information.

If you use my old script I advise you to switch to WhichBrowser.

navigator

Below you see the objects contained by the object navigator. These variables can be read out and give information about the browser and computer of your users.

navigator.geolocation = [object Geolocation]
navigator.webkitPersistentStorage = [object StorageQuota]
navigator.webkitTemporaryStorage = [object StorageQuota]
navigator.doNotTrack = null
navigator.onLine = true
navigator.product = Gecko
navigator.appCodeName = Mozilla
navigator.userAgent = Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.146 Safari/537.36
navigator.platform = MacIntel
navigator.appVersion = 5.0 (Macintosh; Intel Mac OS X 10_9_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.146 Safari/537.36
navigator.appName = Netscape
navigator.vendorSub =
navigator.vendor = Google Inc.
navigator.productSub = 20030107
navigator.cookieEnabled = true
navigator.mimeTypes = [object MimeTypeArray]
navigator.plugins = [object PluginArray]
navigator.language = en-US
navigator.javaEnabled = function javaEnabled() { [native code] }
navigator.getStorageUpdates = function getStorageUpdates() { [native code] }
navigator.registerProtocolHandler = function registerProtocolHandler() { [native code] }
navigator.webkitGetGamepads = function webkitGetGamepads() { [native code] }
navigator.webkitGetUserMedia = function webkitGetUserMedia() { [native code] }
navigator.vibrate = function vibrate() { [native code] }

Browser detect的更多相关文章

  1. Window.navigator

    定义和用法 userAgent 属性是一个只读的字符串,声明了浏览器用于 HTTP 请求的用户代理头的值. 一般来讲,它是在 navigator.appCodeName 的值之后加上斜线和 navig ...

  2. DamonOehlman/detect-browser

    https://github.com/DamonOehlman/detect-browser detect-browser This is a package that attempts to det ...

  3. MetaMask/metamask-extension-provider

    用来探测你的浏览器中有没有安装metamask插件 https://github.com/MetaMask/metamask-extension-provider MetaMask Extension ...

  4. JS: How to detect my browser version and operating system using JavaScript?

    Example: 1. for IE 11,  navigator.userAgent  returns "Mozilla/5.0 (Windows NT 6.1; WOW64; Tride ...

  5. python flask detect browser language

    python flask detect browser language   No problem. We won't show you that ad again. Why didn't you l ...

  6. javascript: detect mobile devices or browser

    http://detectmobilebrowsers.com/ http://hgoebl.github.io/mobile-detect.js/ http://www.hand-interacti ...

  7. PHP: Browser, Operating System (OS), Device, and Language Detect

    https://github.com/sinergi/php-browser-detector Device.php: <!DOCTYPE html> <html> <h ...

  8. C#检测浏览器类型 Detect Browser

    private void Button1_Click(object sender, System.EventArgs e) { System.Web.HttpBrowserCapabilities b ...

  9. 解决ubuntu 14.04 下eclipse 3.7.2 不能启动,报Could not detect registered XULRunner to use 或 org.eclipse.swt.SWTError: XPCOM 等问题的处理

    对于eclipse 3.7.2在ubuntu 14.04下不能启动,需要在 eclipse/configuration 目录下的config.ini文件内增加一行org.eclipse.swt.bro ...

随机推荐

  1. hibernate get VS load

    1.  执行get方法:会立即加载对象      而执行load方法,若不适用该对象,则不会立即执行查询操作,而返回一个代理对象      get立即检索,load延迟检索  2.  load方法可能 ...

  2. 郑州轻工业OJ1400--这不可能是情书吧

    地址:http://acm.zzuli.edu.cn/problem.php?id=1400 #include<stdio.h> #include<string.h> #inc ...

  3. 杭电ACM2097--Sky数

    这题思路很简单,把10,12,16进制数都按位相加,然后进行比较即可. http://acm.hdu.edu.cn/showproblem.php?pid=2097 <span style=&q ...

  4. NDK 通过java调用so文件

    首先我们来看so文件的来源 1. 自己写.c文件,然后生成so库 2. 引用别人的静态库,或者动态库来生成新的jni调用库. 我们先来看最简单的编写一个jni调用的so库,包含一个获取字符串的方法,通 ...

  5. 层叠水平(stacking level)

    运用上图的逻辑,上面的题目就迎刃而解,inline-blcok 的 stacking level 比之 float 要高,所以无论 DOM 的先后顺序都堆叠在上面. 不过上面图示的说法有一些不准确,按 ...

  6. windows bat脚本实现ftp自动下载 删除

    现在有一个需求就是把远程某个文件下面的图片,下载到本地,并且删除下载成功的的文件,而且远程目录下的那个图片会随时增加.假设一下如果所有的脚本都写好了,那么就需要调用windows上的计划任务定时执行脚 ...

  7. DML,DDL,DCL,DQL的区别

      DML 英文缩写 DML = Data Manipulation Language,数据操纵语言,命令使用户能够查询数据库以及操作已有数据库中的数据的计算机语言.具体是指是UPDATE更新.INS ...

  8. mysql中log

    mysql的主从模式配置 1.改主库配置文件:D:\Program Files\MySQL\MySQL Server 5.5(my.ini/my.cnf)在下面加入 [mysqld] log=c:/a ...

  9. Python-Day9 Paramiko模块/进程/线程/RabbitMQ队列

    一.Paramiko模块 1.Paramiko安装 Python的目录下有个Scripts目录,cd到这个目录用这里面的pip命令(如果添加的环境变量可以在cmd直接输入命令):pip install ...

  10. PHP前端$.ajax传递数据到后台

    <html> <head> <meta http-equiv="Content-Type" content="text/html; char ...