# BYOND object (JavaScript)

Source: https://ref.dm-lang.org/skin/control/browser/BYOND

The BYOND object is a built-in shortcut for interacting with the client via JavaScript in a browser control. When the object is created, a custom `byond-ready` event is dispatched to both the document and the window.

The object contains the following methods:

## BYOND.winset(id, params)

Performs a [winset](https://ref.dm-lang.org/skin/control/browser/winset.md), where `id` is the ID of the control to change (or null for global settings), and `params` is an object with parameter,value pairs such as `{"text-color": "red"}`. Parameters can use camelCase, where a capital letter indicates where a hyphen would normally go, e.g. `"textColor"` and `"text-color"` are the same.

```dm
// uncheck a button from JavaScript
BYOND.winset("inventory_button", {isChecked: false});
```

## BYOND.winget(id, props)

Sends a [winget](https://ref.dm-lang.org/skin/control/browser/winset.md), where `id` is the ID of the control to retrieve (or null for global settings), and `props` is a single property or an array of properties to retrieve. As with `winset`, camelCase is allowed, but the result will not use camelCase.

Returns a Promise object, so this call can be used with the `await` keyword or followed by `then()`. The result inside the promise is an object with parameter,value pairs, such as `{"background-color": {value: "#ff0000", red: 255, green: 0, blue: 0, isDefault: false}}`.

```dm
// get a button's status JavaScript
let buttonData = await BYOND.winget("inventory_button", "isChecked");
if(buttonData["is-checked"]) {
    alert("The button is checked!");
}
```

## BYOND.command(command)

Initiates a [client command](https://ref.dm-lang.org/skin/commands/index.md). This is basically just a shortcut for using `winset` to run a command.

```dm
// play a sound
BYOND.command(".sound 'ding.ogg'");
```

## BYOND.topic(params)

Sends a topic string to [client.Topic()](https://ref.dm-lang.org/client/proc/Topic.md), where `params` is an object with parameter,value pairs. This will automatically [url_encode](https://ref.dm-lang.org/proc/url_encode.md) the params object into a topic string.

### See also
> [browser control (skin)](https://ref.dm-lang.org/skin/control/browser/index.md)
