admin管理员组文章数量:1332889
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!
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!
Share Improve this question asked Mar 28, 2013 at 20:59 JackJack 9,79418 gold badges77 silver badges115 bronze badges 6- This doesn't answer your question, but may allow you to test with IE in the future - habdas/emulating-ie-with-virtualbox – Paul Grime Commented Apr 2, 2013 at 21:36
- there may be some differences in how IE handles iframes printing, you'd better provide the URL of the website, or a source of HTML page(including CSS) that resembles the issue. – fitheflow Commented Apr 2, 2013 at 23:23
- I've found that someone else reported a similar issue for IE here – fitheflow Commented Apr 2, 2013 at 23:44
- why not use ajax to get the values? this seems like such an odd workaround. Plus... after you set the values, you don't have to worry about them not printing. – robert Commented Apr 7, 2013 at 20:56
- please check the links it may helpful stackoverflow./questions/4442344/… stackoverflow./questions/2518256/… – Arunkumar Commented Apr 9, 2013 at 6:04
5 Answers
Reset to default 1The 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 ment 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
:
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
This was an interesting point, so I did a test using IE8 (on a server, not locally).
I printed in IE8 a web page that included an iframe of something that I built. And it printed some of the contents the first time (the other contents showed up black). The second time I printed, the iframe contents were all black.
However, in my example, the contents in the iframe are changing constantly (images and text that fade in and out) and the css background behind it is black.
This test has the contents of the iFrame on a different host server than the contents of the main page. But to my knowledge, there is a cross-domain policy file working here.
Cross-domain policy issues were my first guess, but it's entirely possible there is some issue with how internet explorer renders the screenshot when it sends it to the printer.
If you are using Javascript, then why not try window.print()
function along with print media CSS
.
I can't explain why IE isn't working, but maybe you can fix the problem by adding this part of code into the parent page, in order to force each iframe to be refresh :
$(document).ready(function() {
if($.browser.msie) {//Only for IE
$('iframe').each(function() {
$(this).attr('src', $(this).attr('src'));
});
}
});
To get the browser, i use this method.
And i don't use contentDocument.location.reload(true);
method to be sure the iframe to be refresh. See SO topic.
Try this Plugin it will solved your problem http://projects.erikzaadi./jQueryPlugins/jQuery.printElement/
本文标签:
版权声明:本文标题:internet explorer - JavaScript: When printing a full web page, IE doesn't seem to print the contents of iFrames on the p 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742308019a2450306.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论