Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > why is this code not working - printing a pop up

Reply
Thread Tools

why is this code not working - printing a pop up

 
 
Asad Khan
Guest
Posts: n/a
 
      06-03-2004
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!
 
Reply With Quote
 
 
 
 
Vincent van Beveren
Guest
Posts: n/a
 
      06-03-2004
> 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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why are "Array#push" and "pop" not "push!" and "pop!"? samppi Ruby 27 12-05-2007 07:24 AM
brochure printing,online yearbook,printing,books printing,publishing elie Computer Support 0 08-21-2007 05:28 AM
brochure printing,online yearbook,printing,books printing,publishing elie Computer Support 0 08-18-2007 10:11 AM
why why why why why Mr. SweatyFinger ASP .Net 4 12-21-2006 01:15 PM
findcontrol("PlaceHolderPrice") why why why why why why why why why why why Mr. SweatyFinger ASP .Net 2 12-02-2006 03:46 PM



Advertisments