why is this code not working - printing a pop up

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Asad Khan

    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 createPrintPage Header(x) {

    x.document.writ e("<HTML>\n") ;
    x.document.writ e("<HEAD>\n") ;
    x.document.writ e("<TITLE>Repor t</TITLE>\n");
    x.document.writ e("</HEAD>\n");
    x.document.writ e("<BODY>\n") ;

    }
    function createPrintPage Footer(x) {

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

    }

    function doPrint() {

    printWin=open(' ','printWindow' ,'resizable=no, width=690,heigh t=600,menuba
    r=yes,status=ye s,scrollbars=ye s');
    createPrintPage Header(printWin );

    printWin.docume nt.write('foo') ;

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

    createPrintPage Footer(printWin );

    }

    </script>
    </head>

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


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

    #2
    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.docume nt.write('<form >');
    > printWin.docume nt.write('<inpu t type=\"button\" value=\"Print contents
    > of popup\" onclick=\"self. print()\">');
    > printWin.docume nt.write('</form>');
    >[/color]

    You can better use window.print();

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

    The rest looks fine to me.

    Comment

    Working...