Created
August 19, 2015 12:28
-
-
Save victorjonsson/921096ff09fefb6e3000 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
window.addEventListener("load", function() { | |
var self = window.self, | |
parent = window.parent, | |
setTransparentBackground = function(doc) { | |
doc.getElementsByTagName('html')[0].style.background = 'transparent'; | |
doc.getElementsByTagName('body')[0].style.background = 'transparent'; | |
}; | |
// make current doc transparent | |
setTransparentBackground(window.document); | |
// Iterate upwards over all iframes frome here | |
while(self != parent) { | |
var parentIframes = parent.document.getElementsByTagName('iframe'), | |
iframe = false, | |
iframeDoc = false; | |
// Find iframe holding this document in parent window | |
for(var i=0; i < parentIframes.length; i++) { | |
iframeDoc = parentIframes[i].contentDocument || parentIframes[i].contentWindow.document; | |
if( iframeDoc === self.document ) { | |
iframe = parentIframes[i]; | |
break; | |
} | |
} | |
if( iframe ) { | |
setTransparentBackground(iframeDoc); | |
iframe.allowTransparency = 'true'; | |
self = parent; | |
parent = self.parent; | |
} else { | |
break; | |
} | |
} | |
}, false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment