Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. EyeDropper
  4. open()

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 insecure contexts (HTTPS), in some or allsupporting browsers.

Experimental:This is anexperimental technology
Check theBrowser compatibility table carefully before using this in production.

TheEyeDropper.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

js
open()open(options)

Parameters

optionsOptional

An options object to pass anAbortSignal signal:

signalOptional

AnAbortSignal. The eyedropper mode will be aborted when theAbortSignal'sabort() method is called.

Return value

APromise 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 thePromise is rejected.

NotAllowedErrorDOMException

Thrown ifopen() is not called via atransient user activation.

InvalidStateErrorDOMException

Thrown if another eye dropper has already opened.

AbortErrorDOMException

Thrown if the user aborts the selection by pressing theEsc key or if the selection is aborted by anAbortController being passed as an argument toopen().

OperationErrorDOMException

Thrown if the selection fails for other reasons.

Specifications

Specification
EyeDropper API
# dom-eyedropper-open

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp