web api instance method
EyeDropper: open() method
Secure contextLimited availability
The EyeDropper.open() method starts the eyedropper mode, returning a promise which is fulfilled once the user has selected a color and exited the eyedropper mode.
Syntax
open()
open(options)
Parameters
optionsOptional- : An options object to pass an
AbortSignalsignal:signalOptional- : An
AbortSignal. The eyedropper mode will be aborted when theAbortSignal’sabort()method is called.
- : An
- : An options object to pass an
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).
- : A string representing the selected color, in hexadecimal sRGB format (
Exceptions
Exceptions are not thrown but returned when the Promise is rejected.
NotAllowedErrorDOMException- : Thrown if
open()is not called via a transient user activation.
- : Thrown if
InvalidStateErrorDOMException- : Thrown if another eye dropper has already opened.
AbortErrorDOMException- : Thrown if the user aborts the selection by pressing the Esc key or if the selection is aborted by an
AbortControllerbeing passed as an argument toopen().
- : Thrown if the user aborts the selection by pressing the Esc key or if the selection is aborted by an
OperationErrorDOMException- : Thrown if the selection fails for other reasons.
Specifications
SpecificationsStandards references are available on the canonical MDN page.
Browser compatibility
Browser compatibilityCompatibility data is available on the canonical MDN page.
See also
- The
EyeDropperinterface it belongs to.