# Namespace: CB_Client

## CB_Client

Static class to manage the current client. It will return itself if it is tried to be instantiated. It can use BrowserDetect (source code rescued).

Source:
  - CrossBase/general/CB_Client.js, line 14
To Do:
  - Think about implementing a getDocumentParents function (similar to `CB_Client.getWindowParents`).
  - Think about implementing "onClose" event (to fire when app/web is going to be closed).

### Methods

#### <static> exit( [allowWindowCloseFallback] [, allowRedirectionFallback] [, redirectionAddress])

  Exits and finishes the script. In a browser, it will try to close the window or at least abandon it redirecting to an empty one (or to a desired URL). In an app (NW.js (formerly node-webkit)/Electron (Electron.js)/Apache Cordova/Adobe PhoneGap/Appcelerator Titanium SDK/Appcelerator TideSDK (Titanium Desktop)/Weixin (WeChat)/etc.), it will try to close the app.

  ##### Parameters:

  Name | Type | Argument | Default | Description
  --- | --- | --- | --- | ---
  `allowWindowCloseFallback` | boolean | <optional> | true | Defines whether to allow using the window.close method as a fallback.
  `allowRedirectionFallback` | boolean | <optional> | true | Defines whether to redirect the current client as a fallback (to the URL defined in the "redirectionAddress" parameter).
  `redirectionAddress` | boolean | <optional> | 'about:blank' | Defines the URL where the current client will be redirected to in the case that the window cannot be closed. Only used if the "allowRedirectionFallback" parameter is set to true.

  Source:
    - CrossBase/general/CB_Client.js, line 557
  To Do:
    - Have in mind iframes (think about it).

#### <static> get() → {string}

  Returns the current web client (if possible) as a string. It uses BrowserDetect (source code rescued) internally.

  Source:
    - CrossBase/general/CB_Client.js, line 107

  ##### Returns:

  Type
    string

#### <static> getAddressWithoutFile(address [, fallbackURL] [, allowsLocal]) → {string}

  Returns the given address without the file (for example, if "http://whatever.com/index.html" is given, it will return "http://whatever.com/").

  ##### Parameters:

  Name | Type | Argument | Default | Description
  --- | --- | --- | --- | ---
  `address` | string |  |  | The address that we want to filter.
  `fallbackURL` | string | <optional> |  | The address that we want it to return in the case that the given one is not allowed (used when "allowsLocal" does not allow a local address). If it contains a file, it will not be stripped out.
  `allowsLocal` | boolean | <optional> | true | Defines whether to allow returning a local address or not. If it is set to false and the address is local, it will return the "fallbackURL" instead (without stripping out the file, if any).

  Source:
    - CrossBase/general/CB_Client.js, line 762

  ##### Returns:

  Type
    string

#### <static> getBoundingClientRectMargin( [leftOrTop]) → {integer}

  Gets the starting pixel of top or left coordinates for getBoundingClientRect (it's not 0 in some Internet Explorer versions).

  ##### Parameters:

  Name | Type | Argument | Default | Description
  --- | --- | --- | --- | ---
  `leftOrTop` | 'left' | 'top' | <optional> | 'left' | String that defines whether we want it to return the values for "left" or for "top".

  Source:
    - CrossBase/general/CB_Client.js, line 798

  ##### Returns:

  Type
    integer

#### <static> getBrowser()

  Alias for `CB_Client.get`.

  Source:
    - CrossBase/general/CB_Client.js, line 97
  See:
    - `CB_Client.get`

#### <static> getBrowserVersion()

  Alias for `CB_Client.getVersion`.

  Source:
    - CrossBase/general/CB_Client.js, line 113
  See:
    - `CB_Client.getVersion`

#### <static> getBrowserVersionMain()

  Alias for `CB_Client.getVersionMain`.

  Source:
    - CrossBase/general/CB_Client.js, line 129
  See:
    - `CB_Client.getVersionMain`

#### <static> getButtonsDown()

  Alias for `CB_Client.getButtons`.

  Source:
    - CrossBase/input/CB_Mouse.js, line 305
  See:
    - `CB_Client.getButtons`

#### <static> getDocument( [mindIframes]) → {Object}

  Returns the document object (having in mind whether the script is running in one iframe or more, if we want).

  ##### Parameters:

  Name | Type | Argument | Default | Description
  --- | --- | --- | --- | ---
  `mindIframes` | boolean | <optional> | `CB_Configuration.CrossBase.MIND_IFRAMES` | If set to true, it will try to get and return the topmost document object. Useful in case the script is running in an iframe or more.

  Source:
    - CrossBase/general/CB_Client.js, line 264

  ##### Returns:

  Type
    Object

#### <static> getDocumentBase() → {Object}

  Returns the document object of the first parent (the topmost one). Useful in case the script is running in an iframe or more.

  Source:
    - CrossBase/general/CB_Client.js, line 246

  ##### Returns:

  Type
    Object

#### <static> getFlashVersion( [asString]) → {array|string}

  Returns the available version of Adobe Flash (formerly Macromedia Flash) plugin, if any, as either an array of strings or as a string.

  ##### Parameters:

  Name | Type | Argument | Default | Description
  --- | --- | --- | --- | ---
  `asString` | boolean | <optional> | false | If set to true, returns the version as a string.

  Source:
    - CrossBase/general/CB_Client.js, line 441

  ##### Returns:

  Type
    array | string

#### <static> getLanguage( [allowNavigatorLanguages] [, PHPAcceptedLanguagesFirst]) → {string}

  Returns the most preferred language as a string.

  ##### Parameters:

  Name | Type | Argument | Default | Description
  --- | --- | --- | --- | ---
  `allowNavigatorLanguages` | boolean | <optional> | `CB_Configuration.CrossBase.CB_Client_allowNavigatorLanguages_DEFAULT` | Defines whether to allow using the window.navigator.languages property (if not available, it will proceed normally).
  `PHPAcceptedLanguagesFirst` | boolean | <optional> | `CB_Configuration.CrossBase.CB_Client_PHPAcceptedLanguagesFirst_DEFAULT` | If it is set to true, it will try to return the accepted languages found out by PHP (if PHP is available) in $_SERVER['HTTP_ACCEPT_LANGUAGE'] or it will proceed normally otherwise.

  Source:
    - CrossBase/general/CB_Client.js, line 47
  To Do:
    - Use other back-end ways to calculate the language (using Node.js, for example).

  ##### Returns:

  Type
    string

#### <static> getLanguages( [allowNavigatorLanguages] [, PHPAcceptedLanguagesFirst]) → {array}

  Returns the most preferred languages as an array of strings.

  ##### Parameters:

  Name | Type | Argument | Default | Description
  --- | --- | --- | --- | ---
  `allowNavigatorLanguages` | boolean | <optional> | `CB_Configuration.CrossBase.CB_Client_allowNavigatorLanguages_DEFAULT` | Defines whether to allow using the window.navigator.languages property (if not available, it will proceed normally).
  `PHPAcceptedLanguagesFirst` | boolean | <optional> | `CB_Configuration.CrossBase.CB_Client_PHPAcceptedLanguagesFirst_DEFAULT` | If it is set to true, it will try to return the accepted languages found out by PHP (if PHP is available) in $_SERVER['HTTP_ACCEPT_LANGUAGE'] or it will proceed normally otherwise.

  Source:
    - CrossBase/general/CB_Client.js, line 78
  To Do:
    - Use other back-end ways to calculate languages (using Node.js, for example).

  ##### Returns:

  Type
    array

#### <static> getLocation( [mindIframes]) → {string}

  Returns the current URL, if possible (having in mind whether the script is running in one iframe or more, if we want).

  ##### Parameters:

  Name | Type | Argument | Default | Description
  --- | --- | --- | --- | ---
  `mindIframes` | boolean | <optional> | `CB_Configuration.CrossBase.MIND_IFRAMES` | If set to true, it will try to get the location of the topmost window object. Useful in case the script is running in an iframe or more.

  Source:
    - CrossBase/general/CB_Client.js, line 742

  ##### Returns:

  Type
    string

#### <static> getLocationWithoutFile( [fallbackURL] [, allowsLocal] [, mindIframes]) → {string}

  Returns the current URL without the file (for example, if "http://whatever.com/index.html" is the current URL, it will return "http://whatever.com/"), if possible (having in mind whether the script is running in one iframe or more, if we want).

  ##### Parameters:

  Name | Type | Argument | Default | Description
  --- | --- | --- | --- | ---
  `fallbackURL` | string | <optional> |  | The address that we want it to return in the case that the current one is not allowed (used when "allowsLocal" does not allow a local address). If it contains a file, it will not be stripped out.
  `allowsLocal` | boolean | <optional> | true | Defines whether to allow returning a local address or not. If it is set to false and the current address is local, it will return the "fallbackURL" instead (without stripping out the file, if any).
  `mindIframes` | boolean | <optional> | `CB_Configuration.CrossBase.MIND_IFRAMES` | If set to true, it will try to get the location of the topmost window object. Useful in case the script is running in an iframe or more.

  Source:
    - CrossBase/general/CB_Client.js, line 785

  ##### Returns:

  Type
    string

#### <static> getNodeJSVersion( [asString]) → {array|string}

  Returns the available version of Node.js (if any), as either an array of strings or as a string.

  ##### Parameters:

  Name | Type | Argument | Default | Description
  --- | --- | --- | --- | ---
  `asString` | boolean | <optional> | false | If set to true, returns the version as a string.

  Source:
    - CrossBase/general/CB_Client.js, line 346

  ##### Returns:

  Type
    array | string

#### <static> getPHPVersion( [asString]) → {array|string}

  Returns the available version of PHP (if any), as either an array of strings or as a string.

  ##### Parameters:

  Name | Type | Argument | Default | Description
  --- | --- | --- | --- | ---
  `asString` | boolean | <optional> | false | If set to true, returns the version as a string.

  Source:
    - CrossBase/general/CB_Client.js, line 321

  ##### Returns:

  Type
    array | string

#### <static> getSilverlightVersion( [asString]) → {array|string}

  Returns the available version of Microsoft Silverlight plugin (if any), as either an array of strings or as a string.

  ##### Parameters:

  Name | Type | Argument | Default | Description
  --- | --- | --- | --- | ---
  `asString` | boolean | <optional> | false | If set to true, returns the version as a string.

  Source:
    - CrossBase/general/CB_Client.js, line 387

  ##### Returns:

  Type
    array | string

#### <static> getTitle() → {string}

  Returns the current document title.

  Source:
    - CrossBase/general/CB_Client.js, line 868

  ##### Returns:

  Type
    string

#### <static> getVersion() → {string}

  Returns the current web client version (if possible) as a string. It uses BrowserDetect (source code rescued) internally.

  Source:
    - CrossBase/general/CB_Client.js, line 123

  ##### Returns:

  Type
    string

#### <static> getVersionMain() → {integer}

  Returns the current web client main version (first number), if possible, as an integer. It uses BrowserDetect (source code rescued) internally.

  Source:
    - CrossBase/general/CB_Client.js, line 139

  ##### Returns:

  Type
    integer

#### <static> getWindow( [mindIframes]) → {Object}

  Returns the window object (having in mind whether the script is running in one iframe or more, if we want).

  ##### Parameters:

  Name | Type | Argument | Default | Description
  --- | --- | --- | --- | ---
  `mindIframes` | boolean | <optional> | `CB_Configuration.CrossBase.MIND_IFRAMES` | If set to true, it will try to get and return the topmost window object. Useful in case the script is running in an iframe or more.

  Source:
    - CrossBase/general/CB_Client.js, line 223

  ##### Returns:

  Type
    Object

#### <static> getWindowBase() → {Object}

  Returns the window object of the first parent (the topmost one). Useful in case the script is running in an iframe or more.

  Source:
    - CrossBase/general/CB_Client.js, line 186

  ##### Returns:

  Type
    Object

#### <static> getWindowParents() → {array}

  Returns all the window objects, parents and last son (main one) in an array (with the topmost parent in the highest index). Useful in case the script is running in an iframe or more.

  Source:
    - CrossBase/general/CB_Client.js, line 151

  ##### Returns:

  Type
    array

#### <static> isRunningLocally( [mindIframes]) → {boolean}

  Tells whether the script is running locally (using "file:" protocol) or not.

  ##### Parameters:

  Name | Type | Argument | Default | Description
  --- | --- | --- | --- | ---
  `mindIframes` | boolean | <optional> | `CB_Configuration.CrossBase.MIND_IFRAMES` | If set to true, it will try to check the protocol of the topmost window object. Useful in case the script is running in an iframe or more.

  Source:
    - CrossBase/general/CB_Client.js, line 481

  ##### Returns:

  Type
    boolean

#### <static> isRunningOnElectron() → {boolean}

  Tells whether the script is running on Electron (Electron.js) or not.

  Source:
    - CrossBase/general/CB_Client.js, line 537

  ##### Returns:

  Type
    boolean

#### <static> isRunningOnNWjs() → {boolean}

  Tells whether the script is running on NW.js (formerly node-webkit) or not.

  Source:
    - CrossBase/general/CB_Client.js, line 518

  ##### Returns:

  Type
    boolean

#### <static> onLanguageChanges(eventFunction [, keepOldFunction] [, useCapture])

  Sets a function to execute when the languagechange event is fired (only for some web clients) or removes it.

  ##### Parameters:

  Name | Type | Argument | Default | Description
  --- | --- | --- | --- | ---
  `eventFunction` | function | null |  |  | Function that represents the event listener that will be called when the event is fired. If a null value is used, the event will be removed.
  `keepOldFunction` | boolean | <optional> | true | Defines whether to also keep the previous listeners or remove them otherwise.
  `useCapture` | boolean | <optional> | false | Defines whether the event we want to add will use capture or not. This parameter will be effective only if the current client supports the addEventListener method and will be used as its third parameter.

  Source:
    - CrossBase/general/CB_Client.js, line 91

#### <static> redirectTo(address [, getData] [, mindIframes])

  Redirects the current client to the desired location (having in mind whether the script is running in one iframe or more, if we want).

  ##### Parameters:

  Name | Type | Argument | Default | Description
  --- | --- | --- | --- | ---
  `address` | string |  |  | The address where we want to go.
  `getData` | string | <optional> |  | Any URL (GET) variables we want to send (as for example "data1=value1&data2=value2").
  `mindIframes` | boolean | <optional> | `CB_Configuration.CrossBase.MIND_IFRAMES` | If set to true, it will try to redirect the topmost window object. Useful in case the script is running in an iframe or more.

  Source:
    - CrossBase/general/CB_Client.js, line 721

#### <static> setTitle(newTitle) → {string}

  Tries to change the document title and returns it.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `newTitle` | newTitle | The desired new title.

  Source:
    - CrossBase/general/CB_Client.js, line 848

  ##### Returns:

  Type
    string

#### <static> supportsCSS3Transform() → {boolean}

  Tells whether CSS3 transform is supported natively or not.

  Source:
    - CrossBase/general/CB_Client.js, line 292

  ##### Returns:

  Type
    boolean

#### <static> supportsCanvas() → {boolean}

  Tells whether the canvas element is supported natively or not.

  Source:
    - CrossBase/general/CB_Client.js, line 280

  ##### Returns:

  Type
    boolean

#### <static> supportsFlash() → {boolean}

  Function that tells whether Adobe Flash (formerly Macromedia Flash) plugin is available or not.

  Source:
    - CrossBase/general/CB_Client.js, line 403

  ##### Returns:

  Type
    boolean

#### <static> supportsNodeJS() → {boolean}

  Function that tells whether Node.js is available (checks the availability of process.versions.node) or not.

  Source:
    - CrossBase/general/CB_Client.js, line 334

  ##### Returns:

  Type
    boolean

#### <static> supportsPHP() → {boolean}

  Function that tells whether PHP is available or not.

  Source:
    - CrossBase/general/CB_Client.js, line 309

  ##### Returns:

  Type
    boolean

#### <static> supportsSilverlight() → {boolean}

  Function that tells whether Microsoft Silverlight plugin is available or not.

  Source:
    - CrossBase/general/CB_Client.js, line 361

  ##### Returns:

  Type
    boolean

#### Search results