Embed another page in an iframe
A page can show another site inside a frame unless that site blocks framing.
In one line
Can show another site inside its own page, unless that site blocks it
A page can show another site inside a frame unless that site blocks framing.
A site can embed a third party page (maps, video, ads, payment forms) and, if it frames you without protection, overlay invisible content for clickjacking. Framing headers and sandbox settings control who can do this.
What it can and can't do
What the user does: You open a page that includes a map, video or payment box.
It can
- Show another site's content in a frame, such as a video, map or payment form
- Limit what the frame may do with sandbox settings
- Pass a few messages back and forth with the frame
It cannot
- Embed sites that tell browsers not to allow framing
- See what you type or click inside the other site
- Use your camera, microphone or location inside the frame unless the page allows it
Browser support
| Browser | Status | First version | Released | Note |
|---|---|---|---|---|
| Chrome | Supported | 1 | 2008-12-11 | None |
| Edge | Supported | 12 | 2015-07-29 | None |
| Firefox | Supported | 1 | 2004-11-09 | None |
| Safari | Supported | 4 | 2009-06-08 | None |
| Safari on iPhone | Supported | 3.2 | 2010-04-03 | All iOS browsers use WebKit |
| Chrome on Android | Supported | 18 | 2012-06-27 | None |
| Samsung Internet | Supported | 1.0 | 2013-04-27 | None |
How a site asks for it
| API | <iframe src sandbox allow>; Content-Security-Policy: frame-ancestors; X-Frame-Options |
| Browser compat keys | html.elements.iframehttp.headers.Content-Security-Policy.frame-ancestorshttp.headers.X-Frame-Options |
| How access is granted | none |
| What the user sees | None (no browser prompt) |
| Needs a secure context (HTTPS) | No |
| Needs a user gesture | No |
| Activation | none |
| How long it lasts | While the frame is on the page; the framed site's own cookies may be blocked as third party |
| How to take it back | Nothing to revoke (no permission is stored) |
| Inside an iframe | This is the iframe boundary: allow attribute lists permissions, sandbox restricts scripts, popups, forms and top navigation |
Typical flow
- Page adds an iframe element
- Browser checks the target's frame-ancestors or X-Frame-Options
- If allowed, content loads with sandbox and allow limits
- Parent cannot read the frame cross-origin
Data you get
Shape: none
No individual data fields. The signal is the access itself.
Technical limits
- frame-ancestors overrides X-Frame-Options when both are present in browsers that support it
- Cross-origin frames cannot read each other's DOM; only postMessage crosses
- Third party cookies in frames are blocked by default in Safari and Firefox, and partitioned or limited in Chrome
- Top-level navigation from a sandboxed frame needs allow-top-navigation (or allow-top-navigation-by-user-activation)
- The parent cannot hide the framed page's own permission prompts or make them look like its own
The story
What it is
A page can show another website inside a frame, unless that site says no.
For you
You see a video, map, chat box, ad or payment form that looks like part of the page. It is really another site running inside a box.
For makers
Embedding lets small teams add maps, videos and payments with one line. Ad and measurement companies rely on it. It also lets another site watch you from inside the page.
Where you see it
| Type | Example | Apps |
|---|---|---|
| video | A blog shows a YouTube video inside its own page without hosting a single file. | YouTube |
| payments | A shop shows the card form from its payment company so the shop never touches card numbers. | Stripe |
| ads | An ad network draws each ad inside a frame so ad code cannot touch the page. | Google Ad Manager |
| games | A game portal runs each game in a frame and shares one ad slot and leaderboard. | Poki, CrazyGames, itch.io |
| productivity | A company wiki embeds a live Figma file or Google Doc. | Notion, Figma |
| security | A scam page hides a bank or social button under a fake one so you click it by mistake. This is called clickjacking. | None named |
| enterprise | A support widget loads chat inside a frame on every page. | Intercom |
Risks
- Clickjacking
- Third party tracking from frames
What the platform says
- MDN: iframe element. Documents how a page can embed another page inside a frame and how sites can control it.
Good uses and abuse
Legitimate uses
- Maps, video and payment widgets
- Embedded ads
- Embedded apps and widgets
Known abuse
- Clickjacking
- Invisible frames for tracking pixels
- Cross-origin phishing overlays
Scores
| Score | Value | Meaning |
|---|---|---|
| Sensitivity | 3 of 5 | How revealing the data is |
| Utility | 5 of 5 | How useful it is to honest apps |
| Friction | 0 of 5 | How much the user has to do |
| Fingerprint bits | Not rated | Rough identifying entropy, when known |
History
- 2010-01, Chrome 4: X-Frame-Options supported to stop clickjacking
- 2015-01, Chrome 40: CSP frame-ancestors supported
- 2018-01, Firefox 58: CSP frame-ancestors supported in Firefox
Related capabilities
Related
- Popover and modal dialog. Can show a box over everything else on the page
- Fenced frames. Can embed a box of content that the page around it cannot look into
Sources
How well checked: Based on official documentation.