Moustafa
Moustafa

Reputation: 27

Print Options Do Not Open

I have an html file in google script with JS, trying to print using the following code. It opens the document without the print options, I still have to do the cmd+P to print. Any idea, please?

function printBadge() {
        var attendee = document.getElementById("info").value; 
        var fullName = "xxx";
        var snb = "xxx";
        var printFonts = "fonts";
        var printStyle = "style";
        var printArea = "badge info";

          w = window.open();
          w.document.write(printFonts + printStyle + printArea).html();
          w.document.close();
          w.focus();
          w.print();
          w.close();
         return false;
      }

Upvotes: 0

Views: 87

Answers (1)

Sunil Chaudhary
Sunil Chaudhary

Reputation: 4743

The reason is this line w.document.write(printFonts + printStyle + printArea).html();. There is no function .html() associated to document.write and when you try to execute it, it fails there and so window gets stuck.

It needs to be w.document.write(printFonts + printStyle + printArea) without .html() function.

Hope it helps. Revert for any doubts.

Upvotes: 3

Related Questions