aspose file tools*
The moose likes Servlets and the fly likes printing frames . . . Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "printing frames . . ." Watch "printing frames . . ." New topic
Author

printing frames . . .

verduka fox
Ranch Hand

Joined: Jan 18, 2001
Posts: 178
I am developing an intranet site using JSP. I have frames to have a navigation bar on the left side of the screen and another navigation bar along the top. One of the buttons on the top frame needs to print the contents of the main frame(see frame definition below of how the frames are laid out). I have tried having the print button call a javascript function:
function printit()
{
top.frames[1].frames[1].frames[1].print();
}
However, it prints the contents of the top navigation frame, not the main frame. Do you know how I can force clicking a button to print the main frame? Any suggestions would be greatly appreciated!
verduka
This is the code for the main frame. It contains two frames. The bottom frame is defined in lower.html.
<HTML>
<HEAD>
<FRAMESET rows="75,*" frameborder=no border=0>
<FRAME src="info.jsp" marginheight="0" marginwidth="0" topmargin="0" leftmargin="0" scrolling="no">
<FRAME src="lower.html" marginheight="0" marginwidth="0" topmargin="0" leftmargin="0">
<NOFRAMES>
<BODY BGCOLOR="#FFFFFF"><P>To view this page, you need a browser that supports frames.</P></BODY>
</NOFRAMES>
</FRAMESET>
</HTML>
-----
lower.html:
<HTML>
<FRAMESET cols="105,*" frameborder=no border=0>
<FRAME src="navigation.jsp" name="buttonframe" marginheight="0" marginwidth="0" topmargin="0" leftmargin="0" scrolling="no">
<FRAME src="select.html" name="displayframe" marginheight="0" marginwidth="0" topmargin="0" leftmargin="0">
<NOFRAMES>
<BODY BGCOLOR="#FFFFFF">
<P>To view this page, you need a browser that supports frames.</P>
</BODY>
</NOFRAMES>
</FRAMESET>
</HTML>

[This message has been edited by verduka fox (edited July 23, 2001).]
verduka fox
Ranch Hand

Joined: Jan 18, 2001
Posts: 178
Does anyone know how to control printing within frames? This is very important. Thanks in advance.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16054
    
  21

This is extremely client-dependent. Print() is a fairly recent addition to JavaScript. Some browsers only understand printing the entire page. In order to prevent a malicious script from doing impolite things to the user's printer/print queues, the script is essentially only allowed to emulate the user pulling down the File/Print menu, which may offer frame/page print options irrespective of your own wishes.
There's three ways to address this: 1) render the frame data into a PDF and/or popup window. 2) Check out the latest info on HTML printing. 3) Do like most sites and provide a "printer friendly" output button that will cause the page to be rendered in a manner more paper-oriented than screen-oriented.


Customer surveys are for companies who didn't pay proper attention to begin with.
verduka fox
Ranch Hand

Joined: Jan 18, 2001
Posts: 178
Tim,
Thanks for replying. Yes, I understand that this is client-dependent. However, we are building an intranet site so this is pretty much controlled. My main question is regarding the javascript syntax to call print for the selected frame: there is something off with my code:
top.frames[1].frames[1].frames[1].print();
Instead of printing the main frame of the window, it prints the top navigation bar. How do I use javascript to force the main frame to print when the print button on the top navigation bar is pressed?
Thanks for your help!

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: printing frames . . .