Skip to content

Instantly share code, notes, and snippets.

@liamness
Last active August 29, 2015 14:18
Show Gist options
  • Save liamness/9c508b5ccc234d7503f5 to your computer and use it in GitHub Desktop.
Save liamness/9c508b5ccc234d7503f5 to your computer and use it in GitHub Desktop.
Fallback for browsers that don't support srcdoc for iframes
(function() {
if(!('srcdoc' in document.createElement('iframe'))) {
var iframes = document.getElementsByTagName('iframe');
for(var i = 0, len = iframes.length; i < len; i++) {
var iframe = iframes[i];
if(iframe.hasAttribute('srcdoc')) {
iframe.src = 'javascript: window.frameElement.getAttribute(\'srcdoc\');';
}
}
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment