Jump to content

How Do I Print Part Of A Window?


marioliveira

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.

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...