dom / latest / eyedropper / open.html /

EyeDropper.prototype.open()

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The EyeDropper.prototype.open() method starts the eyedropper mode, returning a promise which is fulfilled once the user has either selected a color or dismissed the eyedropper mode.

Syntax

open()
open( options )

Parameters

options Optional

An options object to pass an AbortSignal signal:

signal

An AbortSignal. The eyedropper mode will be aborted when the AbortSignal's abort() method is called.

Return value

A Promise that eventually resolves when the user selects a pixel color from the screen.

The promise resolves to an object with the following property:

sRGBHex

A string representing the selected color, in hexadecimal sRGB format (#aabbcc).

Exceptions

Exceptions are not thrown but returned when the Promise is rejected. The promise is rejected in two cases:

  • When the user dismisses the eyedropper mode by pressing the Escape key.
  • When the eyedropper mode is aborted by the AbortController passed as an argument to open().

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
open
95
95
No
No
81
No
No
No
No
No
No
No

See also

© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/EyeDropper/open