0

I want to make a button to print newly created html page and print it staying in the index page of my website. Now I have a workaround, open the page I want to print, immediately open print menu and then redirecting to the main page

window.onload = function () {
   window.print();
   document.location.href = "/";
}

Is there any elegant solution for that?

Ciro Spaciari
  • 630
  • 5
  • 10
  • 1
    This doesn't have anything to do with Node.js. – Tsvetan Ganev Dec 22 '17 at 13:54
  • 1
    Possible duplicate of [Printing a web page using just url and without opening new window?](https://stackoverflow.com/questions/8240472/printing-a-web-page-using-just-url-and-without-opening-new-window) – Ciro Spaciari Dec 22 '17 at 13:55

1 Answers1

0

Your question is already answered here Printing a web page using just url and without opening new window?

MDN has a nice example here

Ciro Spaciari
  • 630
  • 5
  • 10