How to set printer by javascript?

Rate It (1)

Last post 03-15-2008 6:49 PM by jimmy q. 2 replies.

Sort Posts:

  • How to set printer by javascript?

    03-15-2008, 2:21 PM
    • Loading...
    • vohuman
    • Joined on 01-20-2008, 5:55 PM
    • IRAN
    • Posts 31

    This is my code:

    <script language="javascript" type="text/javascript">
    function
    PrintDiv()
    {
        var myContentToPrint = document.getElementById("dv01");
        var myWindowToPrint = window.open('','','width=800,height=600,toolbar=0,scrollbars=-1,status=0,resizable=-1,location=0,directories=0');
        myWindowToPrint.document.write(myContentToPrint.innerHTML);
        myWindowToPrint.document.close();
        myWindowToPrint.focus();
        myWindowToPrint.print();

        myWindowToPrint.close();
    }

    </script> 

    How to set printer by javascript and What should I do not to print HTMLPage Title & number of pages by printer?

    Cheers!
    Bahman
  • Re: How to set printer by javascript?

    03-15-2008, 6:43 PM
    Answer

    Try window.print.

    Here's a great link for learning more about printing: CSS Design: Going to Print 

  • Re: How to set printer by javascript?

    03-15-2008, 6:49 PM
    Answer
    • Loading...
    • jimmy q
    • Joined on 11-02-2006, 5:01 AM
    • Australia
    • Posts 2,488
    • Moderator

    vohuman:
    How to set printer by javascript
     

    Unfortunately that is not possible. Javascript has not control over the client side machine, all it can do here is display the print dialog screen and the user can then select the printer. 

Page 1 of 1 (3 items)
Microsoft Communities
Page view counter