Widget won't load on Edge in iframe



Attempting to include the Timeline Widget within an iframe. It works on Chrome, Firefox and Safari - but fails on Microsoft Edge:

If I use a sandboxed iframe ( with allow-scripts allow-same-origin allow-forms ) then it fails with no error on Edge, but still works on other browsers.

The iframe content is:

<!DOCTYPE html>

        <a class="twitter-timeline" href="https://twitter.com/justinbieber">Tweets by justinbieber</a> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>


To initialize the iframe I’m encoding it into a dataURI, and including on the page like this

<iframe src="data:text/html;charset=utf-8,%3C!DOCTYPE%20html%3E%0A%20%20%20%20%3Chtml%3E%0A%20%20%20%20%20%20%3Chead%3E%0A%20%20%20%20%20%20%3C%2Fhead%3E%0A%20%20%20%20%20%20%3Cbody%3E%0A%0A%20%20%20%20%20%20%20%20%3Ca%20class%3D%22twitter-timeline%22%20href%3D%22https%3A%2F%2Ftwitter.com%2Fjustinbieber%22%3ETweets%20by%20justinbieber%3C%2Fa%3E%20%3Cscript%20async%20src%3D%22https%3A%2F%2Fplatform.twitter.com%2Fwidgets.js%22%20charset%3D%22utf-8%22%3E%3C%2Fscript%3E%0A%0A%20%20%20%20%20%20%3C%2Fbody%3E%0A%20%20%20%20%3C%2Fhtml%3E" sandbox="allow-scripts allow-same-origin allow-forms"></iframe>

From examining the DOM, it appears that it’s running the widget script and making the widget iframe, but it’s then unable to load the iframe content:

This could be some kind of Edge security issue, preventing iframes from dynamically loading iframes for example. But I’m posting here in case it’s something that can be fixed at the Twitter end.

10% of our users use Edge so would be great if they could add Twitter Widgets to their pages.

The Widget must be stored within an iframe as a security measure, because users can add arbitrary content to their pages in addition to the Twitter Widget.

Final Note:

I’m aware that Microsoft browsers didn’t used to support making iframes using dataURIs. But their docs are out of date - Edge now supports making iframes in this way. DataURI iframes on Edge work fine in other ways, e.g. I can run scripts within the iframe.


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.