window print preview called by javascript

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • maminx
    New Member
    • Jul 2008
    • 77

    window print preview called by javascript

    hello all, i want to call window print preview (in browser, File - Print Preview) by javascript, this is the code


    [CODE=javascript] function printpreview()
    {
    var OLECMDID = 7;
    /* OLECMDID values:
    * 6 - print
    * 7 - print preview
    * 1 - open window
    * 4 - Save As
    */
    var PROMPT = 1; // 2 DONTPROMPTUSER
    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(OLECMDID, PROMPT);
    WebBrowser1.out erHTML = "";
    }[/CODE]



    that function triggered by input type this one below

    [HTML]<input type="button" name="printPrab p" id="printPrabp " onclick = "javascript:pri ntpreview();" value="Print Preview" />
    [/HTML]

    but the browser shown an error "document.body. insertAdjacentH TML is not a function"

    any idea please...
    thanks

    regards, maminx
    Last edited by gits; Jul 25 '08, 09:50 AM. Reason: remember to use CODE tags !!!!
  • maminx
    New Member
    • Jul 2008
    • 77

    #2
    print preview called by javascript only works in IE

    hello all, i have a scipt to call window print preview by javascript below

    [CODE=javascript] function printpreview()
    {
    var OLECMDID = 7;
    /* OLECMDID values:
    * 6 - print
    * 7 - print preview
    * 1 - open window
    * 4 - Save As
    */
    var PROMPT = 1; // 2 DONTPROMPTUSER
    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(OLECMDID, PROMPT);
    WebBrowser1.out erHTML = "";
    }
    [/CODE]


    but that's works only in IE, doesn';t works in mozilla. Mozilla shown an error "insertAdjacent HTML is not a function"

    any idea to solve my problem??

    thanks...

    best regards,

    maminx
    Last edited by gits; Jul 28 '08, 06:51 AM. Reason: remember to use CODE-Tags!!!!!

    Comment

    • gits
      Recognized Expert Moderator Expert
      • May 2007
      • 5390

      #3
      your code is IE-specific and i think every-browser implements its own print-preview handling ... for mozilla you may start further search from here

      kind regards

      PS: btw. please use CODE-Tags when posting source code ...

      Comment

      • rohypnol
        New Member
        • Dec 2007
        • 54

        #4
        Try to replace insertAdjacentE lement with appendChild. I have no idea if the print preview will work. For more information, see this page: [deleted]
        Last edited by gits; Jul 28 '08, 08:28 PM. Reason: deleted link according to posting guidelines

        Comment

        • gits
          Recognized Expert Moderator Expert
          • May 2007
          • 5390

          #5
          Originally posted by rohypnol
          Try to replace insertAdjacentE lement with appendChild. I have no idea if the print preview will work. For more information, see this page: [deleted]
          read here for why i removed the link ...

          kind regards
          MOD

          Comment

          • gits
            Recognized Expert Moderator Expert
            • May 2007
            • 5390

            #6
            threads merged ... don't double post questions regarding the same issue!

            regards,
            MOD

            Comment

            Working...