Chrome 65 can't print hidden iframe

I came across what seems like a Chrome 65 bug regarding iframes .

I cannot use the snippet to demonstrate this, so I used this JSFiddle .

The problem is that if iframe is display: none; .print() does not print anything on the specified iframe .

This 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: Do not try to edit this in the fragment, iframes do not work inside them.

+5
source share
1 answer

It may have been a deliberate change, but I don’t know enough to say for sure. It seems that the change was https://crrev.com/526112 if you want to move on to research; There were some drops from Google Docs, so you are not alone in trying to get around this.

I can get around this using

 visibility: hidden; position: absolute; 

on an iframe to mimic the effect of display: none , inferring it from a normal stream, but still allowing it to execute its own layout. https://jsfiddle.net/28w1tomv/

+6
source

Source: https://habr.com/ru/post/1275891/


All Articles