Example 1 — Feature-Detect Text Fragments
MDN pattern: check whether document.fragmentDirective exists.
if (document.fragmentDirective) {
console.log("Your browser supports text fragments.");
} else {
console.log("Text fragments are not supported in your browser.");
} How It Works
- Read the property. Supporting browsers expose a
FragmentDirectiveobject. - Use truthiness. A present object is truthy; missing support is falsy /
undefined. - Branch your UI. Offer deep-link tools only when the check passes.
- No methods needed. You do not call anything on the object for detection.

