Jump to content

How Do I Print Part Of A Window?


marioliveira
 Share

Recommended Posts

Hi. I have a Joomla website where I defined a table to show up in a window inside the main one, with cursors around it based on the overflow concept. I've been looking in these forums and found out ways to print a window, but when I try inserting that code inside the html code showing that table, what I get is the WHOLE window being printed, including what is outside the table area with the cursors. I think probably creating some kind of popup or _blank source window with the table elements only and then print that (sub)window would probably work, but as nonexperienced I don't know how to do it. Can anybody help me out with this? Or maybe there is a better way of doing that. In short, the idea is to print only what is shown inside the cursor delimited area, not all the window where that part is contained.

Edited by Mário Oliveira
Link to comment
Share on other sites

you're on the right track. Get the outerHTML of your table and send it to your popup window . Note that the styling had to be sent as well, you can try linking a style sheet in rather that passing the internal, but this may get you started

			<style>				td{background:yellow}			</style>			<table id="YourTable">				<tr><td>This is my table</td></tr>			</table>			<button onclick="PrintMe()">print</button>			<script>			function PrintMe()			{				var sPrint = document.getElementById("YourTable").outerHTML;				var disp_setting="toolbar=yes,location=no,directories=yes,menubar=yes,";				disp_setting+="resizable=yes,scrollbars=yes,width=750, height=600, left=10, top=10";				var docprint=window.open("","",disp_setting);				docprint.document.open();				docprint.document.write('<html><head><style>td{background:yellow}</style></head>');				docprint.document.write('<body onLoad="self.print()">');				docprint.document.write(sPrint)				docprint.document.write('</body></html>');				docprint.document.close();				docprint.focus();			}			</script>

Link to comment
Share on other sites

You could also use a print-only stylesheet to hide the parts of the page not for printing.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...