GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • MDN
  • HTML: Markup language
  • Elements
  • Global attributes
  • Attributes
  • See all…
  • Responsive images
  • HTML cheatsheet
  • Date & time formats
  • See all…
  • SVG
  • MathML
  • XML
  • CSS: Styling language

This view

  • Original page
  • New address

GeezerVison is showing developer.mozilla.org — Document: fragmentDirective property - Web APIs | MDN

Document: fragmentDirective property

Baseline 2025
Newly available

Since March 2025, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

  • See full compatibility
  • Learn more

The fragmentDirective read-only property of the Document interface returns the FragmentDirective for the current document.

Value

A FragmentDirective object.

Examples

Checking if text fragments are supported

The code below logs whether or not text fragments are supported in your browser by checking for existence of the object. Note that the object is empty, and at present it is mainly intended for feature detection. In the future, it might include other information.

<pre id="log"></pre>
const logElement = document.querySelector("#log");
function log(text) {
  logElement.innerText = text;
}
#log {
  height: 20px;
}
js
if (document.fragmentDirective) {
  log("Your browser supports text fragments.");
} else {
  log("Text fragments are not supported in your browser.");
}

Specifications

Specification
URL Fragment Text Directives
# dom-document-fragmentdirective

Browser compatibility

See also

  • Text fragments
  • ::target-text

Help improve MDN

Learn how to contribute

This page was last modified on Feb 18, 2025 by MDN contributors.

View this page on GitHub • Report a problem with this content
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.