Feedback: irt.org FAQ Knowledge Base Q73
Feedback on: irt.org FAQ Knowledge Base Q73
Sent by Steve Nabors on December 02, 1999 at 13:13:16: - feedback #639
Worth: Very worth reading
Length: Just right
Technical: Just right
Comments: I discovered a way of making the above concept work in MSIE4.0 as well. Using the script provided in Q481 and a print button on FrameA.formA.printbutton, you can move focus to a visible form element (parent.FrameB.formB.textbox.focus()) in frame (Frame B)and submitting that form where the onsubmit="javascript:window.print()" for formB. Frame B will print. The key is moving focus to a visible form element on Frame B, otherwise it will print the Frame A where focus from the print button remains.
Sent by Steve Nabors on January 10, 2000 at 09:09:49: - feedback #717
Worth: Very worth reading
Comments: I'm getting e-mailed on the comment above so here is a working example: In your frame page, make FrameA and FrameB the frame names. Html for framer page below: <html><head></head> <frameset rows="20%,*"> <frame SRC="framea.htm" name="FrameA" noresize> <frame SRC="frameb.htm" name="FrameB" noresize> <noframes> <body> </body> </noframes> </frameset> </html> Html for framea.htm page below: <html><head><script> function printotherframe() { parent.FrameB.formB.textboxb.focus() parent.FrameB.formB.submit() } </script></head> <body> <form name="formA"><input type="button" value="Print the other frame" onclick="printotherframe()"> </body></html> Html for frameb.htm page below: <html><head> <SCRIPT LANGUAGE="JavaScript"></SCRIPT> <SCRIPT LANGUAGE="VBScript"> sub window_onunload
on error resume next ' Just tidy up when we leave to be sure we aren't ' keeping instances of the web-browser control in memory set WB = nothing end sub sub print OLECMDID_PRINT = 6 OLECMDEXECOPT_DONTPROMPTUSER = 2 OLECMDEXECOPT_PROMPTUSER = 1 on error resume next
'IE4 object has different command structure if DA then call WB.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER) else call WB.IOleCommandTarget.Exec(OLECMDID_PRINT ,OLECMDEXECOPT_DONTPROMPTUSER,"","") end if if err.number <> 0 then if DA then ' IE4 they probably cancelled alert "Nothing Printed :" & err.number & " : " & err.description else handle_error ' ie3x give alternate instructions end if end if end sub 'This will be interpreted during loading. 'It will write out the correct webbrowser object depending 'on the browser version. To be sure it works, make sure you 'include this script block in between the body tags. if DA then 'this must be IE4 or greater wbvers="8856F961-340A-11D0-A96B-00C04FD705A2" else 'this must be IE3.x wbvers="EAB22AC3-30C1-11CF-A7EB-0000C05BAE0B" end if document.write "<OBJECT ID=""WB"" WIDTH=0 HEIGHT=0 CLASSID=""CLSID:" document.write wbvers & """> </OBJECT>" </SCRIPT> </head> <body> <form name="formB" action="javascript:window.print()"> <input type="text" name="textboxb" size="12" value="Print Me"> </form> </body></html>
Sent by michel on August 24, 2000 at 03:46:31: - feedback #1661
Comments: parent.otherframe.focus() parent.otherframe.print()
Sent by Ken Tholke on August 27, 2000 at 03:46:43: - feedback #1680
Worth: Worth reading
Technical: Just right
Comments: I wrestled with this problem for nearly a week. Steve's solution reminded me that when you try to print from another frame, the frame you last clicked in is the frame with the focus. The following is what I came up with that works for IE4+, as well as NN4, using a standard three frame set-up ( as shown below ). <HTML> <HEAD> <TITLE>Parent Frame</TITLE> </HEAD> <FRAMESET rows="90, *"> <FRAME name="header" src="name.html"> <FRAMESET cols="18%, 82%"> <FRAME name="navigator" src="another_name.html"> <FRAME name="display" src="still_yet_another_name.html"> </FRAMESET> </FRAMESET> </HTML>
Again, the key is to put the focus on the frame that is supposed to be printed, by invoking "focus()" first. <HTML> <HEAD> <TITLE>Navigator Frame</TITLE> </HEAD> <BODY> <FORM NAME="PrintA"> <INPUT TYPE="button" NAME="PrintB" VALUE=" Print " onClick = "window.display.focus(); window.display.print()"> </FORM> </BODY> </HTML>
Sent by Tom on September 05, 2001 at 03:37:03: - feedback #3126
Worth: Worth reading
Length: Just right
Technical: Just right
Comments: I've noticed that with Netscape 6 it is not possible to put the focus on a frame inside another frame (E.g.:parent.UpperFrame.LowerFrame.focus()), but you can only put focus on the UpperFrame. Does anybody know a workaround? Thankyou. Tommaso
Sent by Steve Brereton on July 26, 2002 at 11:30:16: - feedback #4031
Worth: Very worth reading
Comments: Solved my problem, though I didn't use/want to use a form/button. My implementation is:
|