Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_web_howto thread: Printing Two Frames Together


Message #1 by Darren Wogan <darrenw@s...> on Mon, 26 Mar 2001 11:41:04 +0100
I know that is is possible to print a specific frame (or iframe) from within

a parent frame. E.g.



	<script language="JavaScript1.2">

	<!--



	function printDetails()

	{

		document.iFrDetails.focus()

		document.iFrDetails.print()

	}



	-->

	</script>



	<iframe name="iFrHeading" ................



	<iframe name="iFrDetails" ................



However is it possible to print two frames together (e.g. a heading frame

and a results frame on the same printed page) ? I have a heading on my main

page and an scrollable iframe with the results. But when I want to print the

results I want to get some sort of header and/or description, to go with it



I have a feeling I might have to simply use an 'onBeforePrint()' method,

though again I am not totally sure how to get any specific text printed with

the results using this approach.



Does anyone know the best approach to this? 



(P.S. I am developing for an IE only based application; I know thats

unfriendly to Netscape users, but its not my decision).



______________________________________

Darren Wogan, Consultant

mailto:darrenw@s...

______________________________________

Strategic Thought Ltd.

The Old Town Hall,

4 Queens Road,

Wimbledon,

London,

SW19 8YA.

Tel: +44 (0)20-8410 4000

Fax: +44 (0)20-8410 4030

http://www.strategicthought.co.uk





Message #2 by "Alex Shiell, ITS, EC, SE" <alex.shiell@s...> on Mon, 26 Mar 2001 12:16:08 +0100
print is a method of the window



sow if you call window.print(), it prints the current frame.  You can print

the top level or parent level frameset by calling window.top.print(), or

window.parent.print()



-----Original Message-----

From: Darren Wogan [mailto:darrenw@s...]

Sent: Tuesday, March 27, 2001 12:05 AM

To: ASP Web HowTo

Subject: [asp_web_howto] Printing Two Frames Together





I know that is is possible to print a specific frame (or iframe) from within

a parent frame. E.g.



	<script language="JavaScript1.2">

	<!--



	function printDetails()

	{

		document.iFrDetails.focus()

		document.iFrDetails.print()

	}



	-->

	</script>



	<iframe name="iFrHeading" ................



	<iframe name="iFrDetails" ................



However is it possible to print two frames together (e.g. a heading frame

and a results frame on the same printed page) ? I have a heading on my main

page and an scrollable iframe with the results. But when I want to print the

results I want to get some sort of header and/or description, to go with it



I have a feeling I might have to simply use an 'onBeforePrint()' method,

though again I am not totally sure how to get any specific text printed with

the results using this approach.



Does anyone know the best approach to this? 



(P.S. I am developing for an IE only based application; I know thats

unfriendly to Netscape users, but its not my decision).



______________________________________

Darren Wogan, Consultant

mailto:darrenw@s...

______________________________________

Strategic Thought Ltd.

The Old Town Hall,

4 Queens Road,

Wimbledon,

London,

SW19 8YA.

Tel: +44 (0)20-8410 4000

Fax: +44 (0)20-8410 4030

http://www.strategicthought.co.uk



________________________________________________________________________

Scottish Enterprise Network

http://www.scottish-enterprise.com



Message #3 by Shaun Steckley <SSTECKLEY@P...> on Mon, 26 Mar 2001 08:58:56 -0500
You can see if IE lets you set focus to a <div> tag (I don't know if this is

possible).  If it does, simply place these iframes in one and set focus to

the div tag before printing...





-----Original Message-----

From: Darren Wogan [mailto:darrenw@s...]

Sent: Monday, March 26, 2001 6:05 PM

To: ASP Web HowTo

Subject: [asp_web_howto] Printing Two Frames Together





I know that is is possible to print a specific frame (or iframe) from within

a parent frame. E.g.



	<script language="JavaScript1.2">

	<!--



	function printDetails()

	{

		document.iFrDetails.focus()

		document.iFrDetails.print()

	}



	-->

	</script>



	<iframe name="iFrHeading" ................



	<iframe name="iFrDetails" ................



However is it possible to print two frames together (e.g. a heading frame

and a results frame on the same printed page) ? I have a heading on my main

page and an scrollable iframe with the results. But when I want to print the

results I want to get some sort of header and/or description, to go with it



I have a feeling I might have to simply use an 'onBeforePrint()' method,

though again I am not totally sure how to get any specific text printed with

the results using this approach.



Does anyone know the best approach to this? 



(P.S. I am developing for an IE only based application; I know thats

unfriendly to Netscape users, but its not my decision).



______________________________________

Darren Wogan, Consultant

mailto:darrenw@s...

______________________________________

Strategic Thought Ltd.

The Old Town Hall,

4 Queens Road,

Wimbledon,

London,

SW19 8YA.

Tel: +44 (0)20-8410 4000

Fax: +44 (0)20-8410 4030

http://www.strategicthought.co.uk



Message #4 by Darren Wogan <darrenw@s...> on Mon, 26 Mar 2001 15:53:09 +0100
Cheers Alex,



However, I think you might have missed my point about the scolling aspect.

Perhaps I should have made that a little clearer.



I want to be able to print the full contents of the scrollable frame on the

same sheet as the non-scrollable title columns. If you try and print the

whole window then anything that has scrolled off the bottom of the visible

iframe is not printed, unless you print the iframe itself.



Now if you print the iframe itself you get all the records, but no heading.

If you print the heading and the iframe contents they get printed on

separate sheets of paper. I want to be able to print the heading (possibly

itself in another iframe, possibly on the main frame, doesn't matter which)

and the full contents of the iframe (including the stuff thats scrolled off

the visible) on the same sheet of paper.



I was hoping that perhaps you could select both frames (or select the text

of the headings and the iframe together and effectively 'print the

selection'. I am not sure how to select text via code however. This is

admittedly probably the wrong way of going about it.



I am suspecting that I will have to take the following steps:

* catch the 'window.onBeforePrint()' event, then within it insert some

innerHTML before the first line of the output in the iframe as columns for

the printed text output

* allow the print() to occur on the iframe

* catch the 'window.onAfterPrint()' event, and within that remove the

innerHTML headings text to restore the display to its best visual setting.



I just wondered if there was anything more elegant I could do, or whether I

has missed something somewhere.



Any ideas?



-----Original Message-----

From: Alex Shiell, ITS, EC, SE [mailto:alex.shiell@s...]

Sent: 26 March 2001 12:16

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Printing Two Frames Together





print is a method of the window



sow if you call window.print(), it prints the current frame.  You can print

the top level or parent level frameset by calling window.top.print(), or

window.parent.print()



-----Original Message-----

From: Darren Wogan [mailto:darrenw@s...]

Sent: Tuesday, March 27, 2001 12:05 AM

To: ASP Web HowTo

Subject: [asp_web_howto] Printing Two Frames Together





I know that is is possible to print a specific frame (or iframe) from within

a parent frame. E.g.



	<script language="JavaScript1.2">

	<!--



	function printDetails()

	{

		document.iFrDetails.focus()

		document.iFrDetails.print()

	}



	-->

	</script>



	<iframe name="iFrHeading" ................



	<iframe name="iFrDetails" ................



However is it possible to print two frames together (e.g. a heading frame

and a results frame on the same printed page) ? I have a heading on my main

page and an scrollable iframe with the results. But when I want to print the

results I want to get some sort of header and/or description, to go with it



I have a feeling I might have to simply use an 'onBeforePrint()' method,

though again I am not totally sure how to get any specific text printed with

the results using this approach.



Does anyone know the best approach to this? 



(P.S. I am developing for an IE only based application; I know thats

unfriendly to Netscape users, but its not my decision).



______________________________________

Darren Wogan, Consultant

mailto:darrenw@s...

______________________________________

Strategic Thought Ltd.

The Old Town Hall,

4 Queens Road,

Wimbledon,

London,

SW19 8YA.

Tel: +44 (0)20-8410 4000

Fax: +44 (0)20-8410 4030

http://www.strategicthought.co.uk

Message #5 by "Alex Shiell, ITS, EC, SE" <alex.shiell@s...> on Mon, 26 Mar 2001 16:13:47 +0100
Your suspicions are spot on - that would probably be the only way to do it.



You can select the contents of text boxes and textareas with the select()

method, but it wont work for ordinary text. Only the object or window that

has the focus can have a selection anyway, so you wouldn't be able to select

text from two frames.





-----Original Message-----

From: Darren Wogan [mailto:darrenw@s...]

Sent: Monday, March 26, 2001 3:53 PM

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Printing Two Frames Together





Cheers Alex,



However, I think you might have missed my point about the scolling aspect.

Perhaps I should have made that a little clearer.



I want to be able to print the full contents of the scrollable frame on the

same sheet as the non-scrollable title columns. If you try and print the

whole window then anything that has scrolled off the bottom of the visible

iframe is not printed, unless you print the iframe itself.



Now if you print the iframe itself you get all the records, but no heading.

If you print the heading and the iframe contents they get printed on

separate sheets of paper. I want to be able to print the heading (possibly

itself in another iframe, possibly on the main frame, doesn't matter which)

and the full contents of the iframe (including the stuff thats scrolled off

the visible) on the same sheet of paper.



I was hoping that perhaps you could select both frames (or select the text

of the headings and the iframe together and effectively 'print the

selection'. I am not sure how to select text via code however. This is

admittedly probably the wrong way of going about it.



I am suspecting that I will have to take the following steps:

* catch the 'window.onBeforePrint()' event, then within it insert some

innerHTML before the first line of the output in the iframe as columns for

the printed text output

* allow the print() to occur on the iframe

* catch the 'window.onAfterPrint()' event, and within that remove the

innerHTML headings text to restore the display to its best visual setting.



I just wondered if there was anything more elegant I could do, or whether I

has missed something somewhere.



Any ideas?



-----Original Message-----

From: Alex Shiell, ITS, EC, SE [mailto:alex.shiell@s...]

Sent: 26 March 2001 12:16

To: ASP Web HowTo

Subject: [asp_web_howto] RE: Printing Two Frames Together





print is a method of the window



sow if you call window.print(), it prints the current frame.  You can print

the top level or parent level frameset by calling window.top.print(), or

window.parent.print()



-----Original Message-----

From: Darren Wogan [mailto:darrenw@s...]

Sent: Tuesday, March 27, 2001 12:05 AM

To: ASP Web HowTo

Subject: [asp_web_howto] Printing Two Frames Together





I know that is is possible to print a specific frame (or iframe) from within

a parent frame. E.g.



	<script language="JavaScript1.2">

	<!--



	function printDetails()

	{

		document.iFrDetails.focus()

		document.iFrDetails.print()

	}



	-->

	</script>



	<iframe name="iFrHeading" ................



	<iframe name="iFrDetails" ................



However is it possible to print two frames together (e.g. a heading frame

and a results frame on the same printed page) ? I have a heading on my main

page and an scrollable iframe with the results. But when I want to print the

results I want to get some sort of header and/or description, to go with it



I have a feeling I might have to simply use an 'onBeforePrint()' method,

though again I am not totally sure how to get any specific text printed with

the results using this approach.



Does anyone know the best approach to this? 



(P.S. I am developing for an IE only based application; I know thats

unfriendly to Netscape users, but its not my decision).



______________________________________

Darren Wogan, Consultant

mailto:darrenw@s...

______________________________________

Strategic Thought Ltd.

The Old Town Hall,

4 Queens Road,

Wimbledon,

London,

SW19 8YA.

Tel: +44 (0)20-8410 4000

Fax: +44 (0)20-8410 4030

http://www.strategicthought.co.uk

________________________________________________________________________

Scottish Enterprise Network

http://www.scottish-enterprise.com


  Return to Index