<input type="button" value="Print this Page" onclick="window.print();">
Here, we called print method on onclick event.
Automatically Open the Print Dialogue Box:
Just past above code within header tag.
Then, call printpage() function on body onload. Thats all now print dialogue box will open automatically.