[CLOSED] Load html in window to print an image.

  1. #1

    [CLOSED] Load html in window to print an image.

    Hi,

    I can not see the popup.

    Any suggestion?

    Erro : Uncaught SyntaxError: Unexpected identifier

    var pagina = "<html>" +
                    "<head>" +
                    "<title>Janeala de impressão temporária</title>" +
                    "<script>" +
                    "function step1() {" +
                    "  setTimeout('step2()', 10);" +
                    "}" +
                    "function step2() {" +
                    "  window.print();" +
                    "  window.close();" +
                    "}" +
                    "</scr" + "ipt>" +
                    "</head>" +
                    "<body onLoad='step1()'>" +
                    "<img src='" + url + "'/>" +
                    "</body>" +
                    "</html>";
    
                X.AddScript("var pw = window.open('about:blank', '_new');  pw.document.open();  pw.document.write('"+pagina+"');  pw.document.close();");
    Thanks !
    Last edited by Daniil; Nov 29, 2011 at 6:09 AM. Reason: [CLOSED]
  2. #2
    Hi,

    Please check a resulted script on the JavaScript errors.

    I think you should replace each single quote symbol with \" symbols.

    Though I'd recommend you to define a respective JavaScript function on client side by a common way and call it from server side:
    X.Js.Call("functionName");
    Last edited by Daniil; Nov 29, 2011 at 6:08 AM.
  3. #3
    Works fine. I am posting the code working.
    Someone may need.
    pagina = "<html>" +
                        "<head>" +
                        "<title>Janela de impressão temporária</title>" +
                        "<script>" +
                        "function step1() {" +
                        "  setTimeout(step2(), 10);" +
                        "}" +
                        "function step2() {" +
                        "  window.print();" +
                        "  window.close();" +
                        "}" +
                        "</script>" +
                        "</head>" +
                        "<body onLoad=step1()>" +
                        "<img src=" + url + "/>" +
                        "</body>" +
                        "</html>";
                    X.Js.Call("imprimirImagens('" + pagina + "')");
    js
    var imprimirImagens = function (pagina) {               
                    var pw = window.open('about:blank', '_new');
                    pw.document.open();
                    pw.document.write(pagina);
                    pw.document.close();
                }
    Thanks!!!
  4. #4
    Thanks for the update and sharing.

Similar Threads

  1. [CLOSED] How I print ext:Window content?
    By supera in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Feb 29, 2012, 4:00 PM
  2. [CLOSED] Print image contained in a panel.
    By stoque in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Aug 23, 2011, 6:07 PM
  3. Replies: 6
    Last Post: Feb 18, 2011, 2:12 PM
  4. [CLOSED] Print a Window
    By rthiney in forum 1.x Legacy Premium Help
    Replies: 7
    Last Post: Jun 01, 2010, 10:30 PM
  5. Replies: 1
    Last Post: Mar 25, 2010, 5:59 PM

Tags for this Thread

Posting Permissions