Prova questo....
File : test2031a.html
codice:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Untitled</title> <script language="JavaScript" type="text/javascript"> <!-- function printPreview() { window.open("test2031b.html","pippo","toolbar=no"); } //--> </script> </head> <body> <textarea id="my_textarea" rows="20" cols="80"></textarea> <input type="button" value="Print preview" onclick="printPreview()"> </body> </html>
File : test2031a.html
codice:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Untitled</title> <style type="text/css"> <!-- .btn {} --> </style> <script language="JavaScript" type="text/javascript"> <!-- function myBeforePrintFunction() { document.all.btn.style.visibility = "hidden"; } // function myBeforePrintFunction() function myAfterPrintFunction() { document.all.btn.style.visibility = "visible"; } // function myAfterPrintFunction() window.onbeforeprint = myBeforePrintFunction; window.onafterprint = myAfterPrintFunction; //--> </script> </head> <body> <input class="btn" type="button" name="btn" value="Print" onclick="window.print();"/> <script language="JavaScript" type="text/javascript"> <!-- var textToPrint = window.opener.document.getElementById('my_textarea').value; re = /\n/gi; var textToPrint = textToPrint.replace(re," "); document.write(textToPrint); //--> </script> </body> </html>

Rispondi quotando