3 ms·
You can easily add no-js fallback by setting base target in JS instead of HTML. Then append e.g. `?fullpage` to HTML <a> elements and remove this query param wi
by niutech 3y ago
You can easily add no-js fallback by setting base target in JS instead of HTML. Then append e.g. `?fullpage` to HTML <a> elements and remove this query param with JS. With no JS, links will open in the same window with `?fullpage` query param, which return a full page from the backend instead of a fragment.
- nymanjon 3y agoA commenter above mentioned that when you target an `iframe` it sends back the header `Sec-Fetch-Dest: iframe`, so if it doesn't have that then you know it requires the full page and not the snippet. So, yes, easy no JS fall back by dynamically adding the `base` tag. Nothing else needed.
- niutech 3y agoNot all browsers support `Sec-Fetch-Dest: iframe`, URL param works everywhere.