Web Analytics Made Easy -
StatCounter print direct to printer no print dialog box? - CodingForum

Announcement

Collapse
No announcement yet.

print direct to printer no print dialog box?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • print direct to printer no print dialog box?

    hey!

    How can I send current page directly to the default printer using javascripting without show the print dialog box to the user

    right now I m using

    <body onload="window.print(), window.close()>

    waittttiiiiiiinnnnnnnnnnnggggggggggg

  • #2
    This will work for IE only.
    <script>
    function Print() {
    if (document.layers) {
    window.print();
    }
    else
    if (document.all) {
    WebBrowser1.ExecWB(6, 6)
    //use 6, 1 to prompt the print dialog or 6, 6 to omit it;
    WebBrowser1.outerHTML = "";
    }
    }
    </script>
    <object ID="WebBrowser1" WIDTH="0" HEIGHT="0"
    CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2">
    </object>

    <body onLoad="Print()">

    Comment


    • #3
      I would strongly advise you don't do that, because[list=1][*]How do you know the user even has a printer?[*]Legally ... forcing a print like that without user interaction could be construed as theft (of electricity, paper and ribbon ink)[/list=1]
      "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

      Comment


      • #4
        hey guys thanks alot for the help... I'll chk it out the Jyoung's code

        brothercake I have used that body tag in a page which loaded when use clicks a print button located on other page.

        Comment

        Working...
        X