Print a page using javascript

Print a page using Java Script:

<html>
<head>
<script>
function printpage(){
        window.print();
}
</script>
</head>
<body>
<h>This is Printing Page</h>
<button onClick = "printpage()">Print</button>
</body>
</html>