-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path16-window-object.js
66 lines (53 loc) · 1.35 KB
/
16-window-object.js
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
/**
* ******************************
* A Look at the Window Object
* ******************************
**/
/**
* ********************
* WINDOW METHODS / OBJECTS / PROPERTIES
* ********************
**/
// Alert
alert('Hello World');
// Prompt
const input = prompt();
alert(input);
// Confirm
if (confirm('Are you sure')) {
console.log('YES'); // OK button.
} else {
console.log('NO'); // Cancel button.
}
let val;
// Outer height and width
val = window.outerHeight;
val = window.outerWidth;
// Inner height and width
val = window.innerHeight;
val = window.innerWidth;
// Scroll points
val = window.scrollY; // Vertical
val = window.scrollX; // Horizontal
// Location Object
val = window.location;
val = window.location.hostname;
val = window.location.port; // port number
val = window.location.href; // full Host name & Port number
val = window.location.search; // http search criteria
// Redirect
window.location.href = 'http://google.com';
// Reload
window.location.reload();
// History Object
window.history.go(-2); // move 2 web pages backwards in the web history
val = window.history.length;
// Navigator Object
val = window.navigator;
val = window.navigator.appName;
val = window.navigator.appVersion;
val = window.navigator.userAgent;
val = window.navigator.platform;
val = window.navigator.vendor;
val = window.navigator.language;
console.log(val);