-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnew_tab_print_close.html
61 lines (53 loc) · 1.73 KB
/
new_tab_print_close.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<!doctype html>
<html>
<head>
<meta charset="utf-8" content="width=device-width, height=device-height">
<title>New Tab Print</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
</head>
<style>
.box {
height: 50vh;
width: 50vw;
}
.background{
background-color: rgb(0, 0, 255);
color-adjust: exact;
}
</style>
<script>
function printAndClose() {
const myWindow = window.open();
myWindow.document.write("<html><head><title>Print New Tab Close</title></head>");
myWindow.document.write("<h1>New Tab Print</h1>");
myWindow.document.write("<p> This website sends the user out to a new tab to print.</p>");
myWindow.document.write("<h2>Info</h2>");
myWindow.document.write("<ul><li>List 1</li><li>List 2</li><li>List 3</li></ul> ");
myWindow.document.write("<p>When you print this window, it will close afterward.</p>");
myWindow.document.write("</body></html>");
myWindow.print();
myWindow.close();
}
</script>
<div class="container">
<h1 class="pt-4 ">New Tab Print</h1>
<div class="alert alert-primary" role="alert">
Just a banner.
</div>
<h2>Print</h2>
<div class="row">
<div class="col-6">
<button class="btn btn-primary btn-lg" onclick="printAndClose();">Print Page</button>
</div>
</div>
<h2>Info</h2>
<p>
This is a simple print test. This website opens a new tab for printing. It also takes care of closing the window.
</p>
<ul>
<li>List 1</li>
<li>List 2</li>
<li>List 3</li>
</ul>
</div>
</html>