demo · v140
highlightsFromPoint
Three Custom Highlights are painted on the paragraph below. Hover anywhere over the text — the readout shows which highlights live at that exact pixel, via document.highlightsFromPoint(x, y).
API not detected
document.highlightsFromPoint needs Chrome 140+. The demo falls back to a manual hit-test over the registered ranges.
note
quote
error
Hover the text:
A note is a short remark that adds context. "A quote sits inside, distinct from the rest." Sometimes a passage contains an erorr — a typo or misspelling — that we want to call out specifically.
Highlights at the pointer:
Move pointer over the text…
const hits = document.highlightsFromPoint(e.clientX, e.clientY);
for (const entry of hits) {
// entry.highlight is the Highlight
console.log(entry.highlight);
}
see also
- highlightsFromPoint API — feature index
- ChromeStatus entry