January 2017
Beginner to intermediate
550 pages
10h 6m
English
Lets practice the following exercise:
setInterval(function () {
document.title = new Date().toTimeString();
}, 1000);
var w = window.open(
'http://phpied.com', 'my',
'width = 200, height = 200');
var i = setInterval((function () {
var size = 200;
return function () {
size += 5;
w.resizeTo(size, size);
if (size === 400) {
clearInterval(i);
}
};
}()), 100);
Every 100 ms (1/10th of a second) the pop-up size increases by five pixels. You keep a reference to the interval i so you can clear it once done. The variable size tracks the pop-up size (and why not keep it private inside a closure). ...
Read now
Unlock full access