Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaScript: When printing a full web page, IE doesn't seem to print the contents of iFrames on the page

The client's website has product listings. The prices for the product are pulled dynamically in through an iFrame at the bottom of the page. There is Javascript on the page that automatically resizes this iFrame to the correct height based upon how big the iFrame content is, once it's loaded.

The client is reporting that when printing the page, they cannot see anything from the iFrame where the prices should be - apparently it is not printing in IE, just the main page itself.

I am on a Mac and so can't test in IE, so I'm having a hard time experimenting with this.

Can anyone clarify the expected behaviour in this situation? Is it possible to get IE to print both page and included iFrames by default, and if so, how would I go about doing this? I can only find examples for printing a specific frame from a parent window.

Thanks!

like image 562
Jack Avatar asked Mar 28 '13 20:03

Jack


1 Answers

The expected behaviour should be what you're experiencing in other browsers. If the page is printed, the iframe should be printed along with it. It would be difficult to imagine that everyone else got it wrong and IE got it correct in this instance.

Below is a bit of speculation on what the issue might be, but without knowing more/seeing code it's difficult to know the specifics:

This issue could be due to some css that you may have on your page. I've read of similar iframe printing issues where the visibility was set to hidden initially resulting in the iframe not printing correctly. To get around this specific case the user had to set the width and height to 0px. Without knowing more about your site, I can not correctly predict that this is happening.

Another issue may by your dynamic resizing based on the contents of the iframe. A simple test would be to comment that section out and set a generic width and height on the iframe to see if the printing issue still occurs. Perhaps those dynamic styles are not being carried over to the print stylesheet and are not getting applied (therefore not appearing at all).

As a quick suggestion, look into css media types:

print

Intended for paged material and for documents viewed on screen in print preview mode. Please consult the section on paged media for information about formatting issues that are specific to paged media.

Helpful link: Print Specification

like image 116
Chase Avatar answered Sep 22 '22 20:09

Chase