Skip to content

Commit

Permalink
Correctly render iframes. Closes #100.
Browse files Browse the repository at this point in the history
Code for detecting if browser enforced same origin policy for iframes
using different src protocols was not working correctly and an exception
was being thrown. This meant that some browsers were not able to
generate iframes for the examples.
  • Loading branch information
marrs committed Nov 27, 2013
1 parent cc4b33b commit 5cc70f0
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions share/docs.previews.js
Expand Up @@ -68,8 +68,13 @@ var iframeEl = document.createElement('iframe');
iframeEl.src = 'data:text/html,';
bodyEl.appendChild(iframeEl);
iframeEl.addEventListener('load', function() {
var support = { sameOriginDataUri: false };
if (this.contentDocument) support.sameOriginDataUri = true;
var support = { sameOriginDataUri: true };
try {
this.contentDocument;
if (!this.contentDocument) support.sameOriginDataUri = false;
} catch (e) {
support.sameOriginDataUri = false;
}
this.parentNode.removeChild(this);
// Loop through code textareas and render the code in iframes.
forEach(bodyEl.getElementsByTagName('textarea'), function(codeEl, idx) {
Expand Down

0 comments on commit 5cc70f0

Please sign in to comment.