why is this code not working - printing a pop up

A

Asad Khan

It makes all the sense in the world, but its not working. Any idea why?
Click the popup button to popup a new screen, and then click the print
button on the popup (which doesn't do anything!).

<html>

<head>
<title>UGH!</title>

<script type="text/javascript">

function createPrintPageHeader(x) {

x.document.write("<HTML>\n");
x.document.write("<HEAD>\n");
x.document.write("<TITLE>Report</TITLE>\n");
x.document.write("</HEAD>\n");
x.document.write("<BODY>\n");

}
function createPrintPageFooter(x) {

x.document.write("</BODY>\n");
x.document.write("</HTML>\n");

}

function doPrint() {

printWin=open('','printWindow','resizable=no,width=690,height=600,menuba
r=yes,status=yes,scrollbars=yes');
createPrintPageHeader(printWin);

printWin.document.write('foo');

printWin.document.write('<form>');
printWin.document.write('<input type=\"button\" value=\"Print contents
of popup\" onclick=\"self.print()\">');
printWin.document.write('</form>');

createPrintPageFooter(printWin);

}

</script>
</head>

<body>
<p>This is just a paragraph. </p>
<form>
<input type="button" value="PopUp" name="btnPopUp"
onclick="doPrint()"></p>
</form>
</body>
</html>


*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 
V

Vincent van Beveren

It makes all the sense in the world, but its not working. Any idea why?
Click the popup button to popup a new screen, and then click the print
button on the popup (which doesn't do anything!).

printWin.document.write('<form>');
printWin.document.write('<input type=\"button\" value=\"Print contents
of popup\" onclick=\"self.print()\">');
printWin.document.write('</form>');

You can better use window.print();

Also it would be more compatible if you use printWin.document.open();
before you write the HTML and printWin.document.close(); after all the
content is written.

The rest looks fine to me.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,526
Members
44,997
Latest member
mileyka

Latest Threads

Top