SOLVED: Hide certain contents of page to be loaded into iframe

Thanks @webdev for pointing me to the solution:

Script in the head:

<script>
$(document).ready(function() {
   var windowURL = window.location.href;
   console.log(windowURL);
   if (windowURL.indexOf('noheaderfooter') > -1) {
     $('#header').css('display', 'none');
     $('#footer').css('display', 'none');
   }
});
</script> 

Content of the page within the iframe looks sth like this:

<div id="header">
  …header content…
</div>
<div id="footer">
  …footer content…
</div>

And then I load the content into the iframe sth like this:

<iframe src="…domain.com/page?noheaderfooter">