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. It has the ability to listen for window specific events.

Methods

(static) create(options) → {Promise.<_Window>}

Creates a new Window.

Parameters:
Name Type Description
options Window~options

Window creation options

Tutorials:
Returns:
Type
Promise.<_Window>

(static) getCurrent() → {Promise.<_Window>}

Asynchronously returns a Window object that represents the current window

Tutorials:
Returns:
Type
Promise.<_Window>

(static) getCurrentSync() → {_Window}

Synchronously returns a Window object that represents the current window

Tutorials:
Returns:
Type
_Window

(async, static) wrap(identity) → {Promise.<_Window>}

Asynchronously returns a Window object that represents an existing window.

Parameters:
Name Type Description
identity Identity
Tutorials:
Returns:
Type
Promise.<_Window>

(static) wrapSync(identity) → {_Window}

Synchronously returns a Window object that represents an existing window.

Parameters:
Name Type Description
identity Identity
Tutorials:
Returns:
Type
_Window

addListener(eventType, listener, optionsopt) → {Promise.<this>}

Adds a listener to the end of the listeners array for the specified event.

Parameters:
Name Type Attributes Description
eventType string | symbol

The type of the event.

listener function

Called whenever an event of the specified type occurs.

options SubOptions <optional>

Option to support event timestamps.

Tutorials:
Returns:
Type
Promise.<this>

animate(transitions, options) → {Promise.<void>}

Performs the specified window transitions.

Parameters:
Name Type Description
transitions Transition

Describes the animations to perform. See the tutorial.

options TransitionOptions

Options for the animation. See the tutorial.

Tutorials:
Returns:
Type
Promise.<void>

authenticate(userName, password) → {Promise.<void>}

Provides credentials to authentication requests

Parameters:
Name Type Description
userName string

userName to provide to the authentication challenge

password string

password to provide to the authentication challenge

Tutorials:
Returns:
Type
Promise.<void>

blur() → {Promise.<void>}

Removes focus from the window.

Tutorials:
Returns:
Type
Promise.<void>

bringToFront() → {Promise.<void>}

Brings the window to the front of the window stack.

Tutorials:
Returns:
Type
Promise.<void>

center() → {Promise.<void>}

Centers the window on its current screen.

Tutorials:
Returns:
Type
Promise.<void>

close(forceopt) → {Promise.<void>}

closes the window application

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.

Tutorials:
Returns:
Type
Promise.<void>

disableUserMovement() → {Promise.<void>}

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

Tutorials:
Returns:
Type
Promise.<void>

enableUserMovement() → {Promise.<void>}

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

Tutorials:
Returns:
Type
Promise.<void>

executeJavaScript(code) → {Promise.<void>}

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

Parameters:
Name Type Description
code string

JavaScript code to be executed on the window.

Tutorials:
Returns:
Type
Promise.<void>

findInPage(searchTerm, options) → {Promise.<number>}

Find and highlight text on a page.

Parameters:
Name Type Description
searchTerm string

Term to find in page

options FindInPageOptions

Search options

Tutorials:
Returns:
Type
Promise.<number>

flash() → {Promise.<void>}

Flashes the window’s frame and taskbar icon until stopFlashing is called or until a focus event is fired.

Tutorials:
Returns:
Type
Promise.<void>

focus() → {Promise.<void>}

Gives focus to the window.

Tutorials:
Fires:
  • _Window#event:focused
Returns:
Type
Promise.<void>

getAllFrames() → {Promise.<Array.<FrameInfo>>}

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

Tutorials:
Returns:
Type
Promise.<Array.<FrameInfo>>

getBounds() → {Promise.<Bounds>}

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

Tutorials:
Returns:
Type
Promise.<Bounds>

(async) getCurrentViews() → {Promise.Array.<View>}

EXPERIMENTAL

Retrieves window's attached views.

Tutorials:
  • Tutorial: Window.getCurrentViews
Returns:
Type
Promise.Array.<View>

getGroup() → {Promise.<Array.<(_Window|ExternalWindow)>>}

Retrieves an array containing wrapped fin.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.

Tutorials:
Returns:
Type
Promise.<Array.<(_Window|ExternalWindow)>>

getInfo() → {Promise.<WindowInfo>}

Gets an information object for the window.

Tutorials:
Returns:
Type
Promise.<WindowInfo>

getNativeId() → {Promise.<string>}

Returns the native OS level Id. In Windows, it will return the Windows handle.

Tutorials:
Returns:
Type
Promise.<string>

getOptions() → {Promise.<any>}

Gets the current settings of the window.

Tutorials:
Returns:
Type
Promise.<any>

getParentApplication() → {Promise.<Application>}

Gets the parent application.

Tutorials:
Returns:
Type
Promise.<Application>

getParentWindow() → {Promise.<_Window>}

Gets the parent window.

Tutorials:
Returns:
Type
Promise.<_Window>

(async) getSnapshot(areaopt) → {Promise.<string>}

Gets a base64 encoded PNG snapshot of the window or just part a of it.

Parameters:
Name Type Attributes Description
area Area <optional>

The area of the window to be captured. Omitting it will capture the whole visible window.

Tutorials:
Returns:
Type
Promise.<string>

getState() → {Promise.<string>}

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

Tutorials:
Returns:
Type
Promise.<string>

getWebWindow() → {object}

Gets the Window Object previously getNativeWindow

Tutorials:
Returns:
Type
object

getZoomLevel() → {Promise.<number>}

Returns the zoom level of the window.

Tutorials:
Returns:
Type
Promise.<number>

hide() → {Promise.<void>}

Hides the window.

Tutorials:
Returns:
Type
Promise.<void>

isMainWindow() → {boolean}

Determines if the window is a main window.

Tutorials:
Returns:
Type
boolean

isShowing() → {Promise.<boolean>}

Determines if the window is currently showing.

Tutorials:
Returns:
Type
Promise.<boolean>

joinGroup(target) → {Promise.<void>}

Joins the same window group as the specified window. Joining a group with native windows is currently not supported(method will nack).

Parameters:
Name Type Description
target _Window | ExternalWindow

The window whose group is to be joined

Tutorials:
Returns:
Type
Promise.<void>

leaveGroup() → {Promise.<void>}

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

Tutorials:
Returns:
Type
Promise.<void>

maximize() → {Promise.<void>}

Maximizes the window

Tutorials:
Returns:
Type
Promise.<void>

mergeGroups(target) → {Promise.<void>}

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

Parameters:
Name Type Description
target _Window | ExternalWindow

The window whose group is to be merged with

Tutorials:
Returns:
Type
Promise.<void>

minimize() → {Promise.<void>}

Minimizes the window.

Tutorials:
Returns:
Type
Promise.<void>

moveBy(deltaLeft, deltaTop, options) → {Promise.<void>}

Moves the window by a specified amount.

Parameters:
Name Type Description
deltaLeft number

The change in the left position of the window

deltaTop number

The change in the top position of the window

options WindowMovementOptions

Optional parameters to modify window movement

Tutorials:
Returns:
Type
Promise.<void>

moveTo(left, top, options) → {Promise.<void>}

Moves the window to a specified location.

Parameters:
Name Type Description
left number

The left position of the window

top number

The top position of the window

options WindowMovementOptions

Optional parameters to modify window movement

Tutorials:
Returns:
Type
Promise.<void>

Navigates the window to a specified URL. The url must contain the protocol prefix such as http:// or https://.

Parameters:
Name Type Description
url string

The URL to navigate the window to.

Tutorials:
Returns:
Type
Promise.<void>

Navigates the window back one page.

Tutorials:
Returns:
Type
Promise.<void>

Navigates the window forward one page.

Tutorials:
Returns:
Type
Promise.<void>

on(eventType, listener, optionsopt) → {Promise.<this>}

Adds a listener to the end of the listeners array for the specified event.

Parameters:
Name Type Attributes Description
eventType string | symbol

The type of the event.

listener function

Called whenever an event of the specified type occurs.

options SubOptions <optional>

Option to support event timestamps.

Tutorials:
Returns:
Type
Promise.<this>

once(eventType, listener, optionsopt) → {Promise.<this>}

Adds a one time listener for the event. The listener is invoked only the first time the event is fired, after which it is removed.

Parameters:
Name Type Attributes Description
eventType string | symbol

The type of the event.

listener function

The callback function.

options SubOptions <optional>

Option to support event timestamps.

Tutorials:
Returns:
Type
Promise.<this>

prependListener(eventType, listener, optionsopt) → {Promise.<this>}

Adds a listener to the beginning of the listeners array for the specified event.

Parameters:
Name Type Attributes Description
eventType string | symbol

The type of the event.

listener function

The callback function.

options SubOptions <optional>

Option to support event timestamps.

Tutorials:
Returns:
Type
Promise.<this>

prependOnceListener(eventType, listener, optionsopt) → {Promise.<this>}

Adds a one time listener for the event. The listener is invoked only the first time the event is fired, after which it is removed. The listener is added to the beginning of the listeners array.

Parameters:
Name Type Attributes Description
eventType string | symbol

The type of the event.

listener function

The callback function.

options SubOptions <optional>

Option to support event timestamps.

Tutorials:
Returns:
Type
Promise.<this>

print(optionsopt) → {Promise.<void>}

Prints the window's web page

Parameters:
Name Type Attributes Description
options PrintOptions <optional>

Printer Options

Tutorials:
Returns:
Type
Promise.<void>

reload() → {Promise.<void>}

Reloads the window current page

Tutorials:
Returns:
Type
Promise.<void>

removeAllListeners(eventTypeopt) → {Promise.<this>}

Removes all listeners, or those of the specified event.

Parameters:
Name Type Attributes Description
eventType string | symbol <optional>

The type of the event.

Tutorials:
Returns:
Type
Promise.<this>

removeListener(eventType, listener, optionsopt) → {Promise.<this>}

Remove a listener from the listener array for the specified event. Caution: Calling this method changes the array indices in the listener array behind the listener.

Parameters:
Name Type Attributes Description
eventType string | symbol

The type of the event.

listener function

The callback function.

options SubOptions <optional>

Option to support event timestamps.

Tutorials:
Returns:
Type
Promise.<this>

resizeBy(deltaWidth, deltaHeight, anchor, options) → {Promise.<void>}

Resizes the window by a specified amount.

Parameters:
Name Type Description
deltaWidth number

The change in the width of the window

deltaHeight number

The change in the height of the window

anchor AnchorType

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"

options WindowMovementOptions

Optional parameters to modify window movement

Tutorials:
Returns:
Type
Promise.<void>

resizeTo(width, height, anchor, options) → {Promise.<void>}

Resizes the window to the specified dimensions.

Parameters:
Name Type Description
width number

The change in the width of the window

height number

The change in the height of the window

anchor AnchorType

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"

options WindowMovementOptions

Optional parameters to modify window movement

Tutorials:
Returns:
Type
Promise.<void>

restore() → {Promise.<void>}

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

Tutorials:
Returns:
Type
Promise.<void>

setAsForeground() → {Promise.<void>}

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

Tutorials:
Returns:
Type
Promise.<void>

setBounds(options) → {Promise.<void>}

Sets the window's size and position.

Parameters:
Name Type Description
options WindowMovementOptions

Optional parameters to modify window movement

Properties:
Name Type Description
bounds Bounds

This is a * @type {string} name - name of the window.object that holds the propertys of

Tutorials:
Returns:
Type
Promise.<void>

setZoomLevel(level) → {Promise.<void>}

Sets the zoom level of the window.

Parameters:
Name Type Description
level number

The zoom level

Tutorials:
Returns:
Type
Promise.<void>

show(forceopt) → {Promise.<void>}

Shows the window if it is hidden.

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

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

Tutorials:
Returns:
Type
Promise.<void>

showAt(left, top, force, options) → {Promise.<void>}

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 Default Description
left number

The left position of the window

top number

The right position of the window

force boolean false

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

options WindowMovementOptions

Optional parameters to modify window movement

Tutorials:
Returns:
Type
Promise.<void>

showDeveloperTools() → {Promise.<void>}

Shows the Chromium Developer Tools

Tutorials:
Returns:
Type
Promise.<void>

stopFindInPage(action) → {Promise.<void>}

Stops any findInPage call with the provided action.

Parameters:
Name Type Description
action string

Action to execute when stopping a find in page:
"clearSelection" - Clear the selection.
"keepSelection" - Translate the selection into a normal selection.
"activateSelection" - Focus and click the selection node.

Tutorials:
Returns:
Type
Promise.<void>

stopFlashing() → {Promise.<void>}

Stops the taskbar icon from flashing.

Tutorials:
Returns:
Type
Promise.<void>

stopNavigation() → {Promise.<void>}

Stops any current navigation the window is performing.

Tutorials:
Returns:
Type
Promise.<void>

updateOptions(options) → {Promise.<void>}

Updates the window using the passed options. Values that are objects are deep-merged, overwriting only the values that are provided.

Parameters:
Name Type Description
options *

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

Tutorials:
Returns:
Type
Promise.<void>

Type Definitions

options

Window creation options.

This is the options object required by Window.create.

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%)

alphaMask object <optional>

Experimental. Updatable.
alphaMask turns anything of matching RGB value transparent.
Caveats:

  • runtime key --disable-gpu is required. Note: Unclear behavior on remote Desktop support
  • User cannot click-through transparent regions
  • Not supported on Mac
  • Windows Aero must be enabled
  • Won't make visual sense on Pixel-pushed environments such as Citrix
  • Not supported on rounded corner windows
Properties
Name Type Attributes Default Description
red number <optional>
-1

0-255

green number <optional>
-1

0-255

blue number <optional>
-1

0-255

alwaysOnTop boolean <optional>
false

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

api object <optional>

Configurations for API injection.

Properties
Name Type Attributes Description
iframe object <optional>

Configure if the the API should be injected into iframes based on domain.

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

Controls if the fin API object is present for cross origin iframes.

sameOriginInjection boolean <optional>
true

Controls if the fin API object is present for same origin iframes.

applicationIcon string <optional>
""

Deprecated - use icon instead.

aspectRatio number <optional>
0

Updatable. The aspect ratio of width to height to enforce for the window. If this value is equal to or less than zero, an aspect ratio will not be enforced.

autoShow boolean <optional>
true

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. In the lack of a whitelist, navigation to URLs that match a blacklisted pattern would be prohibited. See here for more details.

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

List of whitelisted URLs.

blacklist Array.<string> <optional>
[]

List of blacklisted 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.

contextMenuSettings object <optional>

Updatable. Configure the context menu when right-clicking on a window.

Properties
Name Type Attributes Default Description
enable boolean <optional>
true

Should the context menu display on right click.

devtools boolean <optional>
true

Should the context menu contain a button for opening devtools.

reload boolean <optional>
true

Should the context menu contain a button for reloading the page.

cornerRounding object <optional>

Updatable. Defines and applies rounded corners for a frameless window. NOTE: On macOS corner is not ellipse but circle rounded by the average of height and width.

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

The height in pixels.

width number <optional>
0

The width in pixels.

customData any <optional>
""

Updatable. 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. NOTE: On macOS defaultCenter is somewhat above center vertically.

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.

sides object <optional>
{top:true,right:true,bottom:true,left:true}

Sides that a window can be resized from.

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. Windows. 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"
taskbarIcon string <optional>
string

Deprecated - use icon instead.Windows.

taskbarIconGroup string <optional>
<application uuid>

Windows. Specify a taskbar group for the window. If omitted, defaults to app's uuid (fin.Application.getCurrentSync().identity.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>
false

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 without waiting for content to be loaded.