-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbomlesson.html
More file actions
183 lines (148 loc) · 4.32 KB
/
bomlesson.html
File metadata and controls
183 lines (148 loc) · 4.32 KB
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<script>
'use strict';
// this code will produce a console log every second
// when count >= max, the interval is cancelled, and the logging will stop
var count = 0;
var max = 10;
var interval = 1000; // interval time in milliseconds
var intervalId = setInterval(function () {
if (count >= max) {
clearInterval(intervalId);
console.log('All done');
} else {
count++;
console.log('Repeating this line ' + count);
}
}, interval);
'use strict';
var delay = 5000; // delay time in milliseconds
var timeoutId = setTimeout(function () {
alert('Here is a delayed hello!');
}, delay);
// to cancel the timeout, you can call
// clearTimeout(timeoutId);
// prior to the delay expiring
// redirect browser to google.com
window.location = 'http://www.google.com';
location.reload(); // reload page, possibly from cache
// --------------------- LECTURE NOTES ---------------------
// <!DOCTYPE html>
// <html lang="en">
// <head>
// <meta charset="UTF-8">
// <title>Browser Object Model</title>
// </head>
// <body>
//
// <script>
// // (function() {
// "use strict";
// Window Object
// global, access on any page. It applied to the given tab that you are on.
// window.alert()
//
// alert();
// system dialogs
// alert
//window.alert("Hello");
// notification of something, doesent return a value or its not expected to have any boolean logic.
// confirm
//confirm("Are you a codeup student?")
// is this person a student or not?
// var isStudent = confirm("Are you a student?"); //returns a boolean value
// console.log("isStudent :", isStudent); // true or false
//
// // trying to have a condition that will output an alert if the person is a student.
// if(isStudent) {
// //alert("They are a student!");
// var studentName = prompt("What is your name?");
// console.log("studentName:", studentName)
// alert(studentName + " is the students name.")
// } else {
// alert("Have a good day!");
// }
// value determines if we display this alert or not.
// prompt ->
// interval and timeouts
// two methods again on the window class
// does not lock up your code!
// Async
//1. run code repeatedly at a given time frame, so for example ever 30 seconds, every, every hour
// function callbackFn() {
// // do something?
// console.log("run again!")
// }
//
// var intervalTime = 1000; //1 second
//
// var stopInterval = setInterval(callbackFn, intervalTime)
//
// console.log("Who goes first?")
//
//
// // what if you want to cancel it?
// var counter = 0;
// var doAction = setInterval(function () {
// console.log("Second Interval")
// counter++;
// if(counter >= 20) clearInterval(doAction)
// }, 500)
//
// // This just for cancelling current intervals.
// //clearInterval(doAction);
//
//
// //1. It only runs once.
//
// var delay = 1200
//
// function timeoutCallBackFn() {
// // alert("Are you ready!"); //is not ASYNC
// }
// // It runs only once after the delay is complete, so if the delay is 1200ms. It will run after
// // 1200ms and then it's completely done.
// setTimeout(timeoutCallBackFn, delay)
//
//
// var doTimeout = setTimeout(function () {
// console.log("Too slow! I win!")
// }, 10000)
//
//
// // Specify the variable name of the timeout that you want to cancel
// // timeout needs to be assigned a variable for this.
// clearTimeout(doTimeout)
//
//
// // after 5 seconds, we will cancel the first setInterval using a setTimeout.
//
// function myStopInterval () {
// console.log("Canceling the first interval timer")
// clearInterval(stopInterval);
// }
//
// setTimeout(myStopInterval,5000)
// window.location
// where you are on that given document or window
// // GOTO that location
// setTimeout(function() {
// window.location = "https://www.google.com"
// }, 5000)
//reload the page.
// setInterval(function () {
// location.reload();
// },5000);
// })();
</script>
</body>
</html>
</script>
</body>
</html>