Class: Window

Window

A basic window that wraps a native HTML window. Provides more fine-grained control over the window state such as the ability to minimize, maximize, restore, etc. By default a window does not show upon instantiation; instead the window's show() method must be invoked manually. The new window appears in the same process as the parent window.

Constructor
Synchronous Methods
Asynchronous Methods

NOTE: Methods annotated with "(static)" are shared methods called on the class (object constructor) itself.

Constructor

new Window(options, callbackopt, errorCallbackopt)

Creates a new Window.

Best practice is to invoke with the new operand. See the window.constructor tutorial for an example. Failure to use the new operand will result in a console warning (but will otherwise succeed).

Parameters:
Name Type Attributes Description
options fin.desktop.Window~options

Window creation options. See options for more details.

callback successCallback <optional>

Called if the method succeeds. See success callback for shape.

errorCallback errorCallback <optional>

Called if there is a network error. See error callback for shape.

Tutorials:

Methods

(static) getCurrent() → {fin.desktop.Window}

Returns an instance of the current window.

Tutorials:
Returns:
Type
fin.desktop.Window

(static) wrap(appUuid, windowName) → {fin.desktop.Window}

Returns a Window object that wraps an existing window.

Parameters:
Name Type Description
appUuid string

The UUID of the application to which the window to be wrapped belongs.

windowName string

The name of the window to be wrapped.

Tutorials:
Returns:
Type
fin.desktop.Window

addEventListener(type, listener, callbackopt, errorCallbackopt)

Registers an event listener on the specified event.

Parameters:
Name Type Attributes Description
type string

The type of the event.

listener function

Called whenever an event of the specified type occurs. It is passed an event object containing information related to the event.

callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

animate(transitions, options, callbackopt, errorCallbackopt)

Performs the specified window transitions.

Parameters:
Name Type Attributes Description
transitions object

Describes the animations to preform. See the tutorial.

options object

Options for the animation. See the tutorial.

callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

authenticate(userName, password, callbackopt, errorCallbackopt)

Provides credentials to authentication requests

Parameters:
Name Type Attributes Description
userName string

userName to provide to the authentication challange

password string

password to provide to the authentication challange

callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

blur(callbackopt, errorCallbackopt)

Removes focus from the window.

Parameters:
Name Type Attributes Description
callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

bringToFront(callbackopt, errorCallbackopt)

Brings the window to the front of the window stack.

Parameters:
Name Type Attributes Description
callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

close(forceopt, callbackopt, errorCallbackopt)

Closes the window.

Parameters:
Name Type Attributes Default Description
force boolean <optional>
false

Close will be prevented from closing when force is false and ‘close-requested’ has been subscribed to for application’s main window.

callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

disableFrame(callbackopt, errorCallbackopt)

Prevents a user from changing a window's size/position when using the window's frame.

Parameters:
Name Type Attributes Description
callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

enableFrame(callbackopt, errorCallbackopt)

Re-enables user changes to a window's size/position when using the window's frame.

Parameters:
Name Type Attributes Description
callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

executeJavaScript(code, callbackopt, errorCallbackopt)

Executes Javascript on the window, restricted to windows you own or windows owned by applications you have created.

Parameters:
Name Type Attributes Description
code string

JavaScript code to be executed on the window.

callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

flash(options, callbackopt, errorCallbackopt)

Flashes the window’s frame and taskbar icon until stopFlashing is called.

Parameters:
Name Type Attributes Description
options object

Configuration parameters of the flash.

callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

focus(callbackopt, errorCallbackopt)

Gives focus to the window.

Parameters:
Name Type Attributes Description
callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

getAllFrames(callbackopt, errorCallbackopt)

Retrieves an array of frame info objects representing the main frame and any iframes that are currently on the page.

Parameters:
Name Type Attributes Description
callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

getBounds(callbackopt, errorCallbackopt)

Gets the current bounds (top, left, width, height) of the window.

Parameters:
Name Type Attributes Description
callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

getGroup(callbackopt, errorCallbackopt)

Retrieves an array containing wrapped fin.desktop.Windows that are grouped with this window. If a window is not in a group an empty array is returned. Please note that calling window is included in the result array.

Parameters:
Name Type Attributes Description
callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

getInfo(callbackopt, errorCallbackopt) → {fin.desktop.Application#windowInfo}

Gets an information object for the window.

Parameters:
Name Type Attributes Description
callback function <optional>

called if the method succeeds. A windowInfo object is passed as an argument.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:
Returns:
Type
fin.desktop.Application#windowInfo

getNativeWindow() → {window}

Returns the native JavaScript "window" object for the window.

Tutorials:
Returns:
Type
window

getOptions(callbackopt, errorCallbackopt)

Gets the current settings of the window.

Parameters:
Name Type Attributes Description
callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

getParentApplication() → {fin.desktop.Application}

Gets the parent application.

Tutorials:
Returns:
Type
fin.desktop.Application

getParentWindow() → {fin.desktop.Window}

Gets the parent window.

Tutorials:
Returns:
Type
fin.desktop.Window

getSnapshot(callbackopt, errorCallbackopt)

Gets a base64 encoded PNG snapshot of the window.

Parameters:
Name Type Attributes Description
callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

getState(callbackopt, errorCallbackopt)

Gets the current state ("minimized", "maximized", or "restored") of the window.

Parameters:
Name Type Attributes Description
callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

getZoomLevel(callbackopt, errorCallbackopt)

Returns the zoom level of the window.

Parameters:
Name Type Attributes Description
callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

hide(callbackopt, errorCallbackopt)

Hides the window.

Parameters:
Name Type Attributes Description
callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

isShowing(callbackopt, errorCallbackopt)

Determines if the window is currently showing.

Parameters:
Name Type Attributes Description
callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

joinGroup(target, callbackopt, errorCallbackopt)

Joins the same window group as the specified window.

Parameters:
Name Type Attributes Description
target fin.desktop.Window

The window whose group is to be joined.

callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

leaveGroup(callbackopt, errorCallbackopt)

Leaves the current window group so that the window can be move independently of those in the group.

Parameters:
Name Type Attributes Description
callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

maximize(callbackopt, errorCallbackopt)

Maximizes the window.

Parameters:
Name Type Attributes Description
callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

mergeGroups(target, callbackopt, errorCallbackopt)

Merges the instance's window group with the same window group as the specified window

Parameters:
Name Type Attributes Description
target fin.desktop.Window

The window whose group is to be merged with.

callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

minimize(callbackopt, errorCallbackopt)

Minimizes the window.

Parameters:
Name Type Attributes Description
callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

moveBy(deltaLeft, deltaTop, callbackopt, errorCallbackopt)

Moves the window by a specified amount.

Parameters:
Name Type Attributes Description
deltaLeft int

The change in the left position of the window.

deltaTop int

The change in the top position of the window.

callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

moveTo(left, top, callbackopt, errorCallbackopt)

Moves the window to a specified location.

Parameters:
Name Type Attributes Description
left int

The left position of the window.

top int

The top position of the window.

callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

Navigates the window to a specified URL.

Parameters:
Name Type Attributes Description
url string

The URL to navigate the window to.

callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

Navigates the window back one page.

Parameters:
Name Type Attributes Description
callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

Navigates the window forward one page.

Parameters:
Name Type Attributes Description
callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

reload(ignoreCacheopt, callbackopt, errorCallbackopt)

Reloads the window current page.

Parameters:
Name Type Attributes Default Description
ignoreCache boolean <optional>
false

Specifies if the cache should be ignored during page reload.

callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

removeEventListener(type, listener, callbackopt, errorCallbackopt)

Removes a previously registered event listener from the specified event.

Parameters:
Name Type Attributes Description
type string

The type of the event

listener function

Called whenever an event of the specified type occurs. It is passed an event object containing information related to the event.

callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

resizeBy(deltaWidth, deltaHeight, anchor, callbackopt, errorCallbackopt)

Resizes the window by a specified amount.

Parameters:
Name Type Attributes Description
deltaWidth int

The change in the width of the window.

deltaHeight int

The change in the height of the window.

anchor string

Specifies a corner to remain fixed during the resize. Can take the values: "top-left", "top-right", "bottom-left", or "bottom-right." If undefined, the default is "top-left".

callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

resizeTo(width, height, anchor, callbackopt, errorCallbackopt)

Resizes the window to the specified dimensions.

Parameters:
Name Type Attributes Description
width int

The change in the width of the window.

height int

The change in the height of the window.

anchor string

Specifies a corner to remain fixed during the resize. Can take the values: "top-left", "top-right", "bottom-left", or "bottom-right." If undefined, the default is "top-left".

callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

restore(callbackopt, errorCallbackopt)

Restores the window to its normal state (i.e., unminimized, unmaximized).

Parameters:
Name Type Attributes Description
callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

setAsForeground(callbackopt, errorCallbackopt)

Will bring the window to the front of the entire stack and give it focus.

Parameters:
Name Type Attributes Description
callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

setBounds(left, top, width, height, callbackopt, errorCallbackopt)

Sets the window's size and position.

Parameters:
Name Type Attributes Description
left int

The left position of the window.

top int

The top position of the window.

width int

The width of the window.

height int

The height of the window.

callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

setZoomLevel(level, callbackopt, errorCallbackopt)

Sets the zoom level of the window.

Parameters:
Name Type Attributes Description
level Number

The zoom level.

callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

show(forceopt, callbackopt, errorCallbackopt)

Shows the window if it is hidden.

Parameters:
Name Type Attributes Default Description
force boolean <optional>
false

Show will be prevented from closing when force is false and ‘show-requested’ has been subscribed to for application’s main window.

callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

showAt(left, top, forceopt, callbackopt, errorCallbackopt)

Shows the window if it is hidden at the specified location. If the toggle parameter is set to true, the window will alternate between showing and hiding.

Parameters:
Name Type Attributes Default Description
left int

The left position of the window.

top int

The right position of the window.

force boolean <optional>
false

Show will be prevented from closing when force is false and ‘show-requested’ has been subscribed to for application’s main window.

callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

stopFlashing(callbackopt, errorCallbackopt)

Stops the taskbar icon from flashing.

Parameters:
Name Type Attributes Description
callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

stopNavigation(callbackopt, errorCallbackopt)

Stops any current navigation the window is performing.

Parameters:
Name Type Attributes Description
callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

updateOptions(options, callbackopt, errorCallbackopt)

Updates the window using the passed options

Parameters:
Name Type Attributes Description
options object

Changes a window's options that were defined upon creation. See tutorial.

callback function <optional>

called if the method succeeds.

errorCallback function <optional>

called if the method fails. The reason for failure is passed as an argument.

Tutorials:

Type Definitions

windowInfo

Object returned by fin.desktop.Window#getInfo.

Type:
  • object
Properties:
Name Type Description
url string

Uniform Resource Locator of the currently loaded page.

title string

Page title appearing in title bar of window. This will be the markup defined in the <title>...</title> element, or the internal name of the window if there is no such element.

options

Window creation options.

This is the options object required by the Window constructor.

Note that name is the only required property — albeit the url property is usually provided as well (defaults to "about:blank" when omitted).

This jsdoc typedef mirrors the WindowOptions TypeScript interface in @types/openfin.

Type:
  • object
Properties:
Name Type Attributes Default Description
accelerator object <optional>

Enable keyboard shortcuts for devtools, zoom, reload, and reload ignoring cache.

Properties
Name Type Attributes Default Description
devtools boolean <optional>
false

If true, enables the devtools keyboard shortcut:
Ctrl + Shift + I (Toggles Devtools)

reload boolean <optional>
false

If true, enables the reload keyboard shortcuts:
Ctrl + R (Windows)
F5 (Windows)
Command + R (Mac)

reloadIgnoringCache boolean <optional>
false

If true, enables the reload-from-source keyboard shortcuts:
Ctrl + Shift + R (Windows)
Shift + F5 (Windows)
Command + Shift + R (Mac)

zoom boolean <optional>
false

If true, enables the zoom keyboard shortcuts:
Ctrl + + (Zoom In)
Ctrl + Shift + + (Zoom In)
Ctrl + - (Zoom Out)
Ctrl + Shift + - (Zoom Out)
Ctrl + Scroll (Zoom In & Out)
Ctrl + 0 (Restore to 100%)

alwaysOnTop boolean <optional>
false

Updatable. A flag to always position the window at the top of the window stack.

autoShow boolean <optional>
false

A flag to automatically show the window when it is created.

backgroundColor string <optional>
"#FFF"

The window’s backfill color as a hexadecimal value. Not to be confused with the content background color (document.body.style.backgroundColor), this color briefly fills a window’s (a) content area before its content is loaded as well as (b) newly exposed areas when growing a window. Setting this value to the anticipated content background color can help improve user experience. Default is white.

contentNavigation object <optional>

Restrict navigation to URLs that match a whitelisted pattern. See here for more details.

Properties
Name Type Attributes Default Description
whitelist Array.<string> <optional>
[]

List of whitelisted URLs.

contextMenu boolean <optional>
true

Updatable. A flag to show the context menu when right-clicking on a window. Gives access to the devtools for the window.

cornerRounding object <optional>

Updatable. Defines and applies rounded corners for a frameless window.

Properties
Name Type Attributes Default Description
height number <optional>
0

The height in pixels.

width number <optional>
0

The width in pixels.

customData string <optional>
""

A field that the user can attach serializable data to to be ferried around with the window options. When omitted, the default value of this property is the empty string ("").

customRequestHeaders Array.<customRequestHeaders> <optional>

Defines list of customRequestHeaders for requests sent by the window.

defaultCentered boolean <optional>
false

Centers the window in the primary monitor. This option overrides defaultLeft and defaultTop. When saveWindowState is true, this value will be ignored for subsequent launches in favor of the cached value.

defaultHeight number <optional>
500

The default height of the window. When saveWindowState is true, this value will be ignored for subsequent launches in favor of the cached value.

defaultLeft number <optional>
100

The default left position of the window. When saveWindowState is true, this value will be ignored for subsequent launches in favor of the cached value.

defaultTop number <optional>
100

The default top position of the window. When saveWindowState is true, this value will be ignored for subsequent launches in favor of the cached value.

defaultWidth number <optional>
800

The default width of the window. When saveWindowState is true, this value will be ignored for subsequent launches in favor of the cached value.

frame boolean <optional>
true

Updatable. A flag to show the frame.

icon string <optional>

Updatable. Inheritable. A URL for the icon to be shown in the window title bar and the taskbar. When omitted, inherits from the parent application.

maxHeight number <optional>
-1

Updatable. The maximum height of a window. Will default to the OS defined value if set to -1.

maximizable boolean <optional>
true

Updatable. A flag that lets the window be maximized.

maxWidth number <optional>
-1

Updatable. The maximum width of a window. Will default to the OS defined value if set to -1.

minHeight number <optional>
0

Updatable. The minimum height of a window.

minimizable boolean <optional>
true

Updatable. A flag that lets the window be minimized.

minWidth number <optional>
0

Updatable. The minimum width of a window.

name string

The name of the window.

opacity number <optional>
1.0

Updatable. A flag that specifies how transparent the window will be. This value is clamped between 0.0 and 1.0.

preloadScripts Array.<preloadScript> <optional>

Inheritable A list of scripts that are eval'ed before other scripts in the page. When omitted, inherits from the parent application.

resizable boolean <optional>
true

Updatable. A flag to allow the user to resize the window.

resizeRegion object <optional>

Updatable. Defines a region in pixels that will respond to user mouse interaction for resizing a frameless window.

Properties
Name Type Attributes Default Description
bottomRightCorner number <optional>
9

The size in pixels of an additional square resizable region located at the bottom right corner of a frameless window.

size number <optional>
7

The size in pixels.

saveWindowState boolean <optional>
true

A flag to cache the location of the window.

shadow boolean <optional>
false

A flag to display a shadow on frameless windows. shadow and cornerRounding are mutually exclusive. On Windows 7, Aero theme is required.

showTaskbarIcon boolean <optional>
true

Updatable. A flag to show the window's icon in the taskbar.

smallWindow boolean <optional>
false

A flag to specify a frameless window that can be be created and resized to less than 41x36px (width x height). Note: Caveats of small windows are no Aero Snap and drag to/from maximize.

state string <optional>
"normal"

The visible state of the window on creation. One of:

  • "maximized"
  • "minimized"
  • "normal"
taskbarIconGroup string <optional>
<application uuid>

Specify a taskbar group for the window. If omitted, defaults to app's uuid (fin.desktop.Application.getCurrent().uuid).

url string <optional>
"about:blank"

The URL of the window.

uuid string <optional>
<application uuid>

The uuid of the application, unique within the set of all Applications running in OpenFin Runtime. If omitted, defaults to the uuid of the application spawning the window. If given, must match the uuid of the application spawning the window. In other words, the application's uuid is the only acceptable value, but is the default, so there's really no need to provide it.

waitForPageLoad boolean <optional>
true

By default (when set to true), the window will not appear until the window object's load event fires. When set to false, the window will appear immediately but will be empty. The user will experience a brief white flash until the content arrives and is rendered. This can be mitigated somewhat by setting the backgroundColor option to some other color compatible with the expected content.