web api instance property
Document: fragmentDirective property
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;
}
if (document.fragmentDirective) {
log("Your browser supports text fragments.");
} else {
log("Text fragments are not supported in your browser.");
}
Interactive exampleOpen the canonical MDN source to run this embedded demo.
Specifications
SpecificationsStandards references are available on the canonical MDN page.
Browser compatibility
Browser compatibilityCompatibility data is available on the canonical MDN page.