# Iframe sandbox attribute

**URL:** https://talk.observablehq.com/t/iframe-sandbox-attribute/193
**Category:** Feedback
**Created:** [February 1, 2018, 8:45pm UTC](https://talk.observablehq.com/t/iframe-sandbox-attribute/193 "2018-02-01T20:45:30Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![mrdavidjcole](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mrdavidjcole/32/53_2.png) [@mrdavidjcole](https://talk.observablehq.com/u/mrdavidjcole)
#### Post date: [February 1, 2018, 8:45pm UTC](https://talk.observablehq.com/t/iframe-sandbox-attribute/193/1 "2018-02-01T20:45:30Z")

</div>

Hi Observable friends,

I noticed that the main iframe for the rendered cell output has the following `sandbox` attribute:

```auto
sandbox="allow-scripts allow-popups allow-forms allow-popups-to-escape-sandbox allow-top-navigation-by-user-activation" 

```

It seems that this breaks video playback in the Wistia player (disclosure: I work there), as seen in this notebook: [Using the Wistia oEmbed endpoint / David Cole | Observable](https://beta.observablehq.com/@mrdavidjcole/testing-observable-with-some-wistia-stuff).

I think that’s because Wistia, in most cases, delivers video using hls.js, which uses Media Source Extensions – and Media Source Extensions doesn’t play nice with that restriction. It appears to be struggling to construct the URL for the video’s `src` attribute. See the `null` in the error message:

```auto
Not allowed to load local resource: blob:null/e0de54c8-b258-4a5a-abb3-4a39c11088c6

```

After [a little experimentation in Glitch](https://wistia-iframe-sandbox-testing.glitch.me/), I found that including `allow-same-origin` in the `sandbox` attribute makes things work.

Would you be down to include that in the iframe’s sandbox attribute? If not, it’d be super helpful if you could help me understand why.

Thank you!

---

<div class="post-metadata">

### Author: ![jashkenas](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/jashkenas/32/1778_2.png) [@jashkenas](https://talk.observablehq.com/u/jashkenas)
#### Post date: [February 1, 2018, 9:01pm UTC](https://talk.observablehq.com/t/iframe-sandbox-attribute/193/2 "2018-02-01T21:01:05Z")

</div>

_Edited, because my first answer was very wrong…_

We can’t add `allow-same-origin` to our `sandbox` attribute, because it would allow cookies, localStorage and sessionStorage to be shared (or interfered with) across notebooks. They’re all hosted on [observableusercontent.com](http://observableusercontent.com).

For example, if you embedded a video in a notebook that sets a cookie containing tracking information about what video you played — a completely unrelated notebook could then read that cookie information out later.

We’ve got some thoughts about potential ways to ease the sandboxing restrictions further, but we’re not ready to make a change quite yet.

Hope that helps!

---

<div class="post-metadata">

### Author: ![mrdavidjcole](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mrdavidjcole/32/53_2.png) [@mrdavidjcole](https://talk.observablehq.com/u/mrdavidjcole)
#### Post date: [February 1, 2018, 9:09pm UTC](https://talk.observablehq.com/t/iframe-sandbox-attribute/193/3 "2018-02-01T21:09:55Z")

</div>

Thanks @jashkenas! I’ll see if we can find a way to detect this sort of thing from our end and (if we can do that) fall back to an alternative playback strategy.

---

<div class="post-metadata">

### Author: ![donmccurdy](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/donmccurdy/32/45_2.png) [@donmccurdy](https://talk.observablehq.com/u/donmccurdy)
#### Post date: [February 9, 2018, 5:35pm UTC](https://talk.observablehq.com/t/iframe-sandbox-attribute/193/4 "2018-02-09T17:35:17Z")

</div>

Thanks for the explanation @jashkenas — Lack of `allow-same-origin` seems to prevent me from using OAuth to Google APIs (like this [working example in Codepen](https://codepen.io/donmccurdy/pen/KQaGYB?editors=1000#)), so if there are ways to safely ease the restrictions in the future, that would be much appreciated!

---

<div class="post-metadata">

### Author: ![Fil](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/fil/32/207_2.png) [@Fil](https://talk.observablehq.com/u/Fil)
#### Post date: [March 6, 2018, 8:54am UTC](https://talk.observablehq.com/t/iframe-sandbox-attribute/193/5 "2018-03-06T08:54:02Z")

</div>

Is this why no video embed codes seem to work? I’ve tried youtube & vimeo but no luck. The best I get is to display the interface (vimeo) - youtube has only a black rectangle.

html`\<video src=….mp4\>` half works.

---

<div class="post-metadata">

### Author: ![jashkenas](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/jashkenas/32/1778_2.png) [@jashkenas](https://talk.observablehq.com/u/jashkenas)
#### Post date: [March 6, 2018, 4:44pm UTC](https://talk.observablehq.com/t/iframe-sandbox-attribute/193/6 "2018-03-06T16:44:34Z")

</div>

Yes, this is why. Both the YouTube and Vimeo embeds try to set cookies, and can’t within the sandbox.

---

<div class="post-metadata">

### Author: ![tom](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/tom/32/2262_2.png) [@tom](https://talk.observablehq.com/u/tom)
#### Post date: [March 13, 2018, 8:32pm UTC](https://talk.observablehq.com/t/iframe-sandbox-attribute/193/7 "2018-03-13T20:32:57Z")

</div>

![](https://canada1.discourse-cdn.com/flex030/uploads/observablehq/original/1X/17d0f6b442efa07a0fe4e26a5aa64dcff5cea0a0.jpg)

We just added custom origins for notebook content, so you can now embed videos from Wistia, YouTube, Vimeo, and so on, and they should work like a charm. The top example from this post works, and here are [some other examples](https://beta.observablehq.com/@tmcw/embedding-stuff-now-works) of embeds working.

---

<div class="post-metadata">

### Author: ![tomlarkworthy](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/tomlarkworthy/32/5940_2.png) [@tomlarkworthy](https://talk.observablehq.com/u/tomlarkworthy)
#### Post date: [August 23, 2020, 2:52pm UTC](https://talk.observablehq.com/t/iframe-sandbox-attribute/193/8 "2020-08-23T14:52:50Z")

</div>

Might be nice to have the ‘allow-presentation’ too (e.g. for Chrome cast).
