Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Print Preview doesn't match printed document in IE 8 & 9

07 Dec 2011   #1
MForrest

Windows 7 Professional 32bit
 
 
Print Preview doesn't match printed document in IE 8 & 9

I'm helping to develop a web application that uses iframes. On the main page (outside of all frames), we have a div that we use to display and print forms. We also have 2 nested iframes; the innermost iframe contains the main page content. When printing, we use extensive CSS and Javascript (contained in the outermost window) to hide everything except the print div.

When I use File > Print Preview, it always displays the correct preview; that is, the outermost window which contains the print div. Printing from the Print Preview works as it should. However, when I use File > Print, it seems to print whatever window has focus, not the entire page (outermost window). Therefore my print div doesn't get printed and all I get is a printout of whatever is currently onscreen. Why doesn't the print out from File > Print match what is shown in the print preview?

A related issue occurs when using JavaScript's window.print(). When I call window.print from within the print div, it prints as it should. But when I call parent.parent.window.print() from within the double-nested iframe, IE still only prints the window that has focus, not the outermost window (as shown by "parent.parent."). And since they just clicked on a button in the innermost frame, the innermost frame has focus, my print div doesn't print and all I get is a printout of whatever is currently onscreen. I have been using "parent.parent" for all other Javascript calls from the nested iframe to the outermost, so I know that's not the problem.

My temporary solution is to focus on the outermost frame when the users mouses out of the nested window (ie, when they mouse up to the file menu)
Code:
window.onmouseout = parent.parent.window.focus();
and focus on the outermost frame when the user clicks the print button that is within the nested frame. I would really rather not do this focusing, especially on mouseout, because it seems to cause some issues when the user pulls up another application.

I have also tried using the onbeforeprint event to focus. The onbeforeprint was triggered, but I couldn't get the focusing to work correctly.

I haven't been able to find anything regarding these problems online; has anybody had similar problems? I would really appreciate any advice. Thanks!


My System SpecsSystem Spec
.
07 Dec 2011   #2
Neutron16

Windows 8.1 ; Windows 7 x86 (Dec2008-Jan2013)
 
 

Have you checked out how other people deal with printing on web?
Take Gmail, for example. When you click on Print link they open a new tab with desired content, which shows print window immediately on opening.
Code:
<html> 
<head> 
bla-bla-bla 
<script> 
function Print(){document.body.offsetHeight;window.print()}; 
</script> </head> 
<body onload="Print()"> ...
or for a new tab other companies do more direct
Code:
<body onload="window.print()">
My System SpecsSystem Spec
Reply

 Print Preview doesn't match printed document in IE 8 & 9




Thread Tools




Similar help and support threads
Thread Forum
IE 11 when select File Print the Print Dialog Box doesn't open
When we install IE11 after installing some systems on a windows 7 32 bit PC; when select File Menu Print action the Print dialog box which should appear doesn't pop up. Not responding at all. Has somebody come accross this issue.
Browsers & Mail
Print preview doesn't work properly in Excel 2010
Hello all, First I made some contents and drew a border from Home > Font > all Borders on an Excel 2010 file. So it became like below image (capture1). After that I wanted to print it so went to File > Print to see its preview. But the problem is that the lines between tue and wed and also...
Microsoft Office
Alternate HP print driver with 'Print Preview' for Photosmart 7520
Help getting & installing a compatable driver for new Photosmart 7520. Need to have 'Print Preview' in Printer Preferences. Newer Photosmart Printers have very few options under Preferences. Have tried drivers for Office Jet 6100 & Deskjet 69800 as suggested in HP forums. Neither has...
Drivers
Print Preview not working (select pics/right click to print)
When I select my pics to print, right click to print, the preview box comes up but nothing shows as a preview. This started when I wiped my operating system clean. It hasn't worked properly since. Thanks for any help
General Discussion
IE8 won't print preview/print web pages
And yet Firefox works fine. Go figure. Help appreciated.
Browsers & Mail


Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 22:56.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App