Cómo establecer la función en el botón cuando haga clic y muestre la ventana. Ejecutar la salida en JS
<button onclick="window.print()">Print this page</button>
Undefined
<button onclick="window.print()">Print this page</button>
console.log("print")
//or
alert("Print")