The Window Object

Browser and Screen Information

The Navigator Object

The navigator property of a Window object refers to a Navigator object that contains browser vendor and version number information.

The Navigator object has four properties

  1. appName, The full name of the web browser
  2. appVersion, This property typically begins with a number and follows that with a detailed string that contains browser vendor and version information.
  3. userAgent,This property typically contains all the information in appVersion and may contain additional details as well.
  4. platform, A string that identifies the operating system (and possibly the hardware) on which the browser is running.

     *Browser sniffing using navigator.userAgent*
     var browser = (function(){
         var s = navigator.userAgent.toLowerCase();
         var match = /(webkit)[ \/]([\w.]+)/.exec(s) || /(opera)(?:.*version)?[ \/]([\w.]+)/.exec(s) ||
         /(msie) ([\w.]+)/.exec(s) ||
         !/compatible/.test(s) && /(mozilla)(?:.*? rv:([\w.]+))?/.exec(s) || [];
         console.log({ name: match[1] || "", version: match[2] || "0" }) ;
     }());
    

The Screen Object

The screen property of a Window object refers to a Screen object that provides information about the size of the user’s display and the number of colors available on it.

properties

  • width, height
  • availWidth, availHeight
  • colorDepth