Print the window without opening Printer Dialogue Box

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • getmeidea
    New Member
    • Feb 2007
    • 36

    Print the window without opening Printer Dialogue Box

    Hi All,

    In javascript i am using the code window.print().
    It opens the printer dialogue box and user has to confirm.
    I need the code to print the page directly without promoting Printer Dialogue Box.

    Thanking you,
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    This is not possible with JavaScript. You may be able to use ActiveX/vbscript, but that would be an IE-only solution which wouldn't work in other browsers.

    Comment

    • getmeidea
      New Member
      • Feb 2007
      • 36

      #3
      Originally posted by acoder
      This is not possible with JavaScript. You may be able to use ActiveX/vbscript, but that would be an IE-only solution which wouldn't work in other browsers.
      Thank you very much for your solution.

      Can you send me the proper code on vbscript which will do this functionality (Working only in IE is fine).

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Try something like:
        [CODE=javascript]var WebBrowser = '<OBJECT ID="WebBrowser1 " WIDTH=0 HEIGHT=0 CLASSID="CLSID: 8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
        document.body.i nsertAdjacentHT ML('beforeEnd', WebBrowser);
        WebBrowser1.Exe cWB(6, -1);
        WebBrowser1.out erHTML = "";[/CODE]
        Note: this assumes IE only. I'm not too sure about the exact settings for the ExecWB method. You could try other numbers if the above doesn't work.

        Comment

        Working...