Document: fragmentDirective property
Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
The fragmentDirective read-only property of the Document interface returns the FragmentDirective for the current document.
Value
A FragmentDirective object.
Examples
Try running the following in a supporting browser's devtools, in a tab with one or more matched text fragments:
js
document.fragmentDirective;
You should get a FragmentDirective object instance returned with a structure similar to the following:
js
items: [
{
prefix: "",
textStart: "Module Workers",
textEnd: "",
suffix: "support",
type: "text",
},
{
prefix: "feedback on",
textStart: "usability",
textEnd: "",
suffix: "",
type: "text",
},
];
This functionality is mainly intended for feature detection at present, but in future, it could be expanded to include other information such as translation hints.
Specifications
| Specification |
|---|
| URL Fragment Text Directives # dom-document-fragmentdirective |
Browser compatibility
BCD tables only load in the browser