<! DOCTYPE html>
<title> Printing </title>
<meta charset= "Utf-8" >
<style>
. printbox {
width:300px;
height:300px;
BORDER:1PX solid blue;
}
</style>
<!--printed Styles--
<style media= "Print" >
@page {
Size:auto;
margin:0mm;
}
</style>
<body>
<div class= "Printbox" >
This is content!!! <br>
Click the button to print
</div>
<button onclick= ' print_page () ' > Printing </button>
</body>
<script type= "Text/javascript" >
function Print_page () {
if (!! Window. ActiveXObject | | "ActiveXObject" in window) {//whether IE
Remove_ie_header_and_footer ();
}
Window.print ();
}
function Remove_ie_header_and_footer () {
var Hkey_path;
Hkey_path = "HKEY_CURRENT_USER\\Software\\Microsoft\\Internet explorer\\pagesetup\\";
try {
var regwsh = new ActiveXObject ("Wscript.Shell");
Regwsh.regwrite (Hkey_path + "header", "");
Regwsh.regwrite (Hkey_path + "footer", "");
} catch (e) {
}
}
</script>
The above is controlled with JS
You can also set it directly on the print page.
JS Control Print Header Footer Date Web site