Re: Print option on page

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello , 
I'm using this script , i hope it can be useful .
#####################################################
// in head section :
<script language="JavaScript">
var gAutoPrint = true; 
function printSpecial()
{
	if (document.getElementById != null)
	{
		var html = '<HTML dir=rtl>\n<HEAD>\n';

		if (document.getElementsByTagName != null)
		{
			var headTags = document.getElementsByTagName("head");
			if (headTags.length > 0)
				html += headTags[0].innerHTML;
		}
		html += '\n</HE' + 'AD>\n<BODY><p align="center"><h2>Page Title</h2></p><div align="center">\n';
		var printReadyElem = document.getElementById("printReady");
		if (printReadyElem != null)
		{
				html += printReadyElem.innerHTML;
		}
		else
		{
			alert("Could not find the printReady section in the HTML");
			return;
		}
		html += '\n<pl></p></div></BO' + 'DY>\n</HT' + 'ML>';
		var printWin = window.open("","printSpecial");
		printWin.document.open();
		printWin.document.write(html);
		printWin.document.close();
		if (gAutoPrint)
			printWin.print();
	}
	else
	{
		alert("Sorry, the print ready feature is only available in modern browsers.");
	}
}
</script>

####################################
// in Body :
<div id="printReady">
 // Your table 
</div>

<p align="center"><a href="javascript:void(printSpecial())"></a></p>

-----------------------------------------------

best regards :
saeed Mulla


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux