PDA

View Full Version : Printing the contents of an IFrame


ScottInTexas
12-20-2002, 08:53 PM
Well, as usual when all else fails and you have bashed your head on the wall, call on the forum. It's me again with yet another question (I beg your patience).

While I can print the contents of an IFrame I am getting the visible contents of the frame, but the frame contains many rows of data in one IFrame and another IFrame with the headers of the data columns. I did this so the data could scroll but the header would remain visible. I put the header in the main IFrame so that it would print with the data table.

Now, is there a way to combine the two IFrames into one then print? Or can I make the javascript print BOTH Iframes in a single job?

For clarity the frames are laid out like this:

MainFrame
hdrFrame -- No scroll
DataFrame- Scroll (can be very long.)
End OF MainFrame


Print the contents of the mainframe

Thanks again.

ScottInTexas
12-20-2002, 09:23 PM
I re-wrote the way I am doing this to use an ASP to write all the data (with header) into the frame. This works. I need to change the mainframe from non-scrolling to scrolling but I get an access denied error.


window.document.frames('dataWindow').scrolling='auto';
window.document.frames('dataWindow').focus();
window.print();


It's the same old error. I think I'm dealing with an object, but it doesn't like the way I try to address the attributes.

Thanks,

ScottInTexas
12-23-2002, 03:47 PM
After much frustration the answer is here.

It required a 2 second delay in order to give the page time to reload the iframe. After inserting the timer I got the results I was looking for. Here is the finished code.


function doPrint(){
dataWindow.location='';
dataWindow.focus();
dataWindow.location="http://.../PrintIt.asp?plant="+ strPlant + "&Region=" + strRegion + "&ReportType=" + strRptType;
var iTimerID = window.setTimeout("window.print()", 2000 , "javascript");

}

function window.onafterprint(){
dataWindow.location='about:blank';
dataWindow.location="http://...DataXfer.asp?plant="+ strPlant + "&Region=" + strRegion + "&ReportType=" + strRptType + "&PrintMe=False";
}


The different ASPs are used because the data is written to the page so completely different.