Last active
August 29, 2015 14:18
-
-
Save liamness/9c508b5ccc234d7503f5 to your computer and use it in GitHub Desktop.
Fallback for browsers that don't support srcdoc for iframes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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