Skip to content

Instantly share code, notes, and snippets.

@vdite
Created June 28, 2013 09:55
Show Gist options
  • Save vdite/5883669 to your computer and use it in GitHub Desktop.
Save vdite/5883669 to your computer and use it in GitHub Desktop.
Collapse iframe if empty with jQuery
// if you are using no caching headers in your iframe sources, so you 'll always get an "filled" iframe. This does kick your layout sometimes.
// this is how to coollapse such iframes:
if($("#iframeid").contents().find("p").length) {
$('#iframeid').css('display', 'none');
}
// this is how to kill all caches in the iframe source
// <head>
// <meta http-Equiv="Cache-Control" Content="no-cache">
// <meta http-Equiv="Pragma" Content="no-cache">
// <meta http-Equiv="Expires" Content="0">
// </head>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment