The most viewed posts

Contact Me

About Me

Myanmar font and keyboard for Windows

Registry Reviver

IT Support & Endpoint Management

Digital Platforms & Web Solutions

How to clean up Windows Computer

Driver Booster

CCleaner

About Desktop Icons in Windows Computer

The most viewed items

Dell Inspiron 5559

SONY Playstation Portable

HP ProBook 430

Laptop RAM

External Hard Disk

Laptop

Desktop Hard Disk

Please login to start chat

ZilaStar ICT Nov 29 2025, 10:44:14
Category : JavaScript Tutorials

How to print a document or webpage

# HTML # 

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="print.js"></script>
<link rel="stylesheet" href="print.css">
</head>
<body>
<button type="button" onclick="printDoc()">Print</button>
<p id="myId">Hello, I am Thet Naing Win. Welcome to zilastar.com.</p>
</body>
</html>

# CSS #
body{
color: red;
}

# JavaScript #
function printDoc(){
var printDoc = document.getElementById("myId").innerHTML;
var a = window.open('', '', 'width=auto; height=auto');
a.document.write("<html><head><title>ZilaStar</title>");
a.document.write("<link rel='stylesheet' href='print.css'>");
a.document.write("</head>");
a.document.write("<body>");
a.document.write(printDoc);
a.document.write("</body>");
a.document.write("</html>");
a.focus();
setTimeout(function(){
a.print();
setTimeout(function(){
a.close();
}, 500)
}, 500);
}

Comments:

 
ZilaStar ICT Dec 10 2025, 19:02:41
hello
To Contact
🙏 About Me
📜Terms and Conditions