Last active
August 29, 2015 14:12
-
-
Save n8io/5021e93d269c85e2d193 to your computer and use it in GitHub Desktop.
Provides a way to hide elements before the page is visible if in an iFrame.
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
<html> | |
<head> | |
</head> | |
<body> | |
<!-- The first element in the body --> | |
<script> | |
function inIframe() { | |
try { | |
return window.self !== window.top; | |
} catch (e) { | |
return true; | |
} | |
} | |
if(inIframe()){ | |
document.getElementsByTagName('body')[0].style.display = 'none'; | |
} | |
</script> | |
... | |
<!-- The last element in the body. --> | |
<script> | |
(function(){ | |
if(inIframe()){ | |
var removeElements = ['topBorder', 'lightLine', 'header', 'navbar container', 'master-footer']; | |
for(var i = 0; i < removeElements.length; i++){ | |
var foundElements = document.getElementsByClassName(removeElements[i]); | |
for(var j = 0; j < foundElements.length; j++){ | |
foundElements[j].style.display = 'none'; | |
} | |
} | |
document.getElementsByTagName('body')[0].style.display = 'block'; | |
} | |
})(); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment