I stumbled upon what seems to be a Chrome 65 bug regarding iframes
.
I can't use a snippet to demonstrate this, so I used this JSFiddle.
The problem is that if the iframe
is display: none;
, the .print()
on said iframe
won't print anything.
It only happens on Chrome 65, not Chrome 64.
Here is the code :
<iframe id="frame"></iframe>
<iframe id="frame2" class="hidden"></iframe>
<button class="db">Print without display: none;</button>
<button class="dn">Print with display: none;</button>
$('.db').on('click',function(){
$('#frame').contents().find('body').append('<p>Test without <code>display: none;</code>!</p>')
$('#frame')[0].contentWindow.print();
});
$('.dn').on('click',function(){
$('#frame2').contents().find('body').append('<p>Test with <code>display: none;</code>!</p>')
$('#frame2')[0].contentWindow.print();
});
.hidden{
display: none;
}
PS : Don't try to edit this into a snippet, the iframes don't work inside them.
This may have been a deliberate change, but I don't know enough to say for sure. The change seems to have been https://crrev.com/526112 if you want to go exploring; there was some fallout from Google Docs so you're not alone in trying to work around this.
I can work around it by using
visibility: hidden;
position: absolute;
on the iframe to simulate the effect of display: none
taking it out of the normal flow but still allowing it to perform its own layout. https://jsfiddle.net/28w1tomv/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With