-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathspy-stub.html
79 lines (70 loc) · 1.92 KB
/
spy-stub.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>AutomationCamp</title>
</head>
<body>
<h1>Session19</h1>
<ul>
<li>
<button id="console-log">Log something</button>
</li>
</ul>
<ul>
<li>
<button id="open-window">Open New Window</button>
</li>
</ul>
<ul>
<li>
<button id="print-window">Print 🖨</button>
</li>
</ul>
<ul>
</ul>
<h5>Alert/Confirm/Prompt</h5>
<ul>
<li><button id="alert" onclick="jsAlert()">Open JS Alert</button></li>
</ul>
<ul>
<li><button id="confirm" onclick="jsConfirm()">Open JS Confirm</button></li>
</ul>
<ul>
<li><button id="prompt" onclick="jsPrompt()">Open JS Prompt</button></li>
</ul>
<h4>Result:</h4>
<p id='result' style='color:green'></p>
<script>
document.getElementById('open-window')
.addEventListener('click', function (event) {
window.open('https://google.com')
})
document.getElementById('print-window')
.addEventListener('click', () => {
window.print()
})
document.getElementById('console-log')
.addEventListener('click', () => {
console.log("Hello World!")
})
function jsAlert() {
alert('I am a JS Alert');
log('You successfully clicked an alert');
}
function jsConfirm() {
var c = confirm('I am a JS Confirm');
var result = c === true ? 'Ok' : 'Cancel';
log('You clicked: ' + result);
}
function jsPrompt() {
var p = prompt('I am a JS Prompt');
log('You entered: ' + p);
}
function log(msg) {
var result = document.getElementById('result');
result.innerHTML = msg;
}
</script>
</body>
</html>