Connecting Tech Pros Worldwide Help | Site Map

why is this code not working - printing a pop up

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 23rd, 2005, 11:22 AM
Asad Khan
Guest
 
Posts: n/a
Default why is this code not working - printing a pop up

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!

  #2  
Old July 23rd, 2005, 11:22 AM
Vincent van Beveren
Guest
 
Posts: n/a
Default Re: why is this code not working - printing a pop up

> It makes all the sense in the world, but its not working. Any idea why?[color=blue]
> 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>');
>[/color]

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.

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.