# BrowserUtil Class

Defined in: `js/util/BrowserUtil.js:12`
Module: util
Parent Module: StructureJS

A helper class to detect OS and browsers.

## Index

Show: Inherited Protected Private Deprecated

### Properties

- _eventDispatcher static
- _onBreakpointChangeHandler static
- _styleDeclaration static
- _window static
- debounceDelay static
- isEnabled static

### Methods

- _onBreakpointChange static
- addEventListener static
- browserName static
- browserVersion static
- dispatchEvent static
- enable static
- getBreakpoint static
- getBrowser static
- hasBrowserHistory static
- hasLocalStorage static
- hasSessionStorage static
- isAndroid static
- isBlackBerry static
- isIEMobile static
- isIOS static
- isMobile static
- isOperaMini static
- removeEventListener static

## Properties

### `_eventDispatcher` EventDispatcher private static

Defined in `js/util/BrowserUtil.js:329`

A reference to the EventDispatcher object.

### `_onBreakpointChangeHandler` Any private static

Defined in `js/util/BrowserUtil.js:356`

TODO: YUIDoc_comment

### `_styleDeclaration` Any private static

Defined in `js/util/BrowserUtil.js:347`

A reference to the getComputedStyle method.

### `_window` Window private static

Defined in `js/util/BrowserUtil.js:338`

A reference to the browser window object.

### `debounceDelay` Number public static

Defined in `js/util/BrowserUtil.js:365`

The delay in milliseconds for the Util.debounce method that dispatches the BaseEvent.RESIZE event to get the your browser breakpoints. See getBreakpoint.

Default: 250

### `isEnabled` Boolean public static

Defined in `js/util/BrowserUtil.js:376`

The isEnabled property is used to keep track of the enabled state of listening for Breakpoint changes.

There are no properties that match your current filter settings. You can change your filter settings in the index section on this page. index

## Methods

### `_onBreakpointChange` () private static

Defined in `js/util/BrowserUtil.js:319`

Dispatches a breakpoint event.

### `addEventListener` () public static

Defined in `js/util/BrowserUtil.js:280`

TODO: YUIDoc_comment

### `browserName` () String public static

Defined in `js/util/BrowserUtil.js:50`

Returns the name of the browser.

#### Returns:

String:

#### Example:

     BrowserUtil.browserName();
     // 'Chrome'

### `browserVersion`
(

- `[majorVersion=true]`

)
Number | String public static

Defined in `js/util/BrowserUtil.js:64`

Returns the version of the browser.

#### Parameters:

- `[majorVersion=true]` Boolean optional

#### Returns:

Number | String:

#### Example:

     BrowserUtil.browserVersion();
     // 39

     BrowserUtil.browserVersion(false);
     // '39.0.2171.99'

### `dispatchEvent` () public static

Defined in `js/util/BrowserUtil.js:302`

TODO: YUIDoc_comment

### `enable` () public static

Defined in `js/util/BrowserUtil.js:25`

Dispatches a breakpoint event.

### `getBreakpoint` () String public static

Defined in `js/util/BrowserUtil.js:247`

Get the current breakpoint from the style sheets. You must add a body:after property with a specific content in each of your style sheets for this functionality to work.

#### Returns:

String:

The string value of the current style sheet.

#### Example:

     // For each of your different style sheets add something like below:
     // screen_lg.css
     body:after {
         content: 'screen_lg';  width: 1px; height: 1px; padding: 0; margin: -1px; border: 0; position: absolute; clip: rect(0 0 0 0); overflow: hidden;
     }
     // screen_sm.css
     body:after {
         content: 'screen_sm';  width: 1px; height: 1px; padding: 0; margin: -1px; border: 0; position: absolute; clip: rect(0 0 0 0); overflow: hidden;
     }

     BrowserUtil.getBreakpoint();
     // 'screen_lg'

     // Add a listener to get notified when the browser is resized:
     BrowserUtil.addEventListener(BaseEvent.RESIZE, this._onBreakpointChange, this);
     ...
     _onBreakpointChange(baseEvent) {
         console.log(baseEvent.data);
         // 'screen_sm'
     }

### `getBrowser` () Array. public static

Defined in `js/util/BrowserUtil.js:89`

Gets the browser name a user agent.

#### Returns:

Array.:

#### Example:

     BrowserUtil.getBrowser();
     // ["Chrome", "39.0.2171.99"]

### `hasBrowserHistory` () Boolean public static

Defined in `js/util/BrowserUtil.js:195`

Determines if the browser can you Browser History push states.

#### Returns:

Boolean:

#### Example:

     BrowserUtil.hasBrowserHistory();
     // true

### `hasLocalStorage` () Boolean public static

Defined in `js/util/BrowserUtil.js:209`

Determines if the browser can you Local Storage.

#### Returns:

Boolean:

#### Example:

     BrowserUtil.hasLocalStorage();
     // true

### `hasSessionStorage` () Boolean public static

Defined in `js/util/BrowserUtil.js:228`

Determines if the browser can you Session Storage.

#### Returns:

Boolean:

#### Example:

     BrowserUtil.hasSessionStorage();
     // true

### `isAndroid` () Boolean public static

Defined in `js/util/BrowserUtil.js:111`

Determines if the device OS is Android.

#### Returns:

Boolean:

#### Example:

     BrowserUtil.isAndroid();
     // false

### `isBlackBerry` () Boolean public static

Defined in `js/util/BrowserUtil.js:125`

Determines if the device OS is Android.

#### Returns:

Boolean:

#### Example:

     BrowserUtil.isBlackBerry();
     // false

### `isIEMobile` () Boolean public static

Defined in `js/util/BrowserUtil.js:167`

Determines if the device OS is IE Mobile.

#### Returns:

Boolean:

#### Example:

     BrowserUtil.isIEMobile();
     // false

### `isIOS` () Boolean public static

Defined in `js/util/BrowserUtil.js:139`

Determines if the device OS is IOS.

#### Returns:

Boolean:

#### Example:

     BrowserUtil.isIOS();
     // false

### `isMobile` () Boolean public static

Defined in `js/util/BrowserUtil.js:181`

Determines if the it is run on a mobile or desktop device.

#### Returns:

Boolean:

#### Example:

     BrowserUtil.isMobile();
     // false

### `isOperaMini` () Boolean public static

Defined in `js/util/BrowserUtil.js:153`

Determines if the device OS is Opera Mini.

#### Returns:

Boolean:

#### Example:

     BrowserUtil.isOperaMini();
     // false

### `removeEventListener` () public static

Defined in `js/util/BrowserUtil.js:292`

TODO: YUIDoc_comment

There are no methods that match your current filter settings. You can change your filter settings in the index section on this page. index