EyeDropper: open() method
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
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.
Return value
Exceptions
Exceptions are not thrown but returned when the Promise is rejected.
NotAllowedErrorDOMException-
Thrown if
open()is not called via a transient user activation. 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(). OperationErrorDOMException-
Thrown if the selection fails for other reasons.
Specifications
| Specification |
|---|
| EyeDropper API # dom-eyedropper-open |
Browser compatibility
BCD tables only load in the browser
See also
- The
EyeDropperinterface it belongs to.