Click to See Complete Forum and Search --> : problem printing a page using document.print


kernschatten
08-22-2003, 10:03 AM
This page only supports I.E. 5+
My page has the following top level flow:
Outer page with navigation -
--iFrame with a 2 panel frameset within it top/bottom (needed to get reporting table columns exactly spaced) (reportFrame)
---Top frame is just a dummy report with the title lines of the frame visibile, rest hidden (reportFrame.topFrame)
---Bottem frame is real report with title lines hidden (reportFrame.mainFrame)
----Bottem frame has another iframe used to re-create a printable report, and other print functions (reportFrame.mainFrame.process)

I have two print functions:
printReport -> uses document.location on reportFrame.mainFrame.process and sets it to the printer-friendly report. This page is cold fusion.
printItemInfo -> two-step process: first is a doc.location on reportFrame.mainFrame.process to a CGI. The CGI then re-directs to a ColdFusion/JavaScript page that does a lot of graphic formatting.

The pages are done in Cold Fusion MX and heavy on the javascript. My problem is that I can print the re-created printer-friendly report from reportFrame.mainFrame.process through <body onLoad"this.focus(); this.print();"> and it works fine. However, when I try the same thing with my second print process (printItemInfo) which uses a lot of javascript, the print doesn't catch. No errors are generated, and javascript after the print calls works. The odd thing is that if I use the browser's back button, the print dialog shows up whenever the previous page is loaded and will then print the current page. I've tried using a call to a function on the top level page, and all the parents that does a blah.frame.focus();blah.frame.print(); and none of those work either. I've also moved the process frame to the top level, and still nothing.

Any Ideas?

Khalid Ali
08-22-2003, 10:47 AM
seems to me that you need to set the focus to problematic frame first.

kernschatten
08-22-2003, 11:49 AM
I don't believe focus is the problem. If I make a button that has window.document.process.focus(); window.document.process.print();
and then click the button after the printItemInfo page loads it will print the correct section, but I don't want the user to have to click another button. I've tried scripting the click to that button, and nothing happens with the print, if I change the button to alert something, the scripted click brings up the alert.

Is there a way to force javascript to stop processing or flush data?

Khalid Ali
08-22-2003, 12:00 PM
in absence of a complete knowledge of your code..I can only say that focus() the frame and print it.And I have not come accross any other problem in this(its pretty straight forward action).
To avoid having th euser click 2 buttons you can have one button set the focus and print the doc as well.