-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy path38_window.js
42 lines (26 loc) · 2.08 KB
/
38_window.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
// In client - side JavaScript, the window object is a global object that represents the browser window or tab in which your JavaScript code is running.It provides access to various browser - related functions and properties.
// Here are some commonly used properties and methods of the window object in JavaScript:
// window.alert() : Displays an alert box with a message and an OK button.
// window.prompt() : Displays a dialog box that prompts the user for input.
// window.confirm() : Displays a dialog box with a message and OK and Cancel buttons.
// window.innerWidth and window.innerHeight : Returns the width and height of the browser window, excluding the toolbar, menu, and scroll bars.
// window.location : Returns an object that contains information about the current URL.
// window.history : Provides access to the browser's session history, allowing you to navigate forward and backward through the user's history.
// window.localStorage and window.sessionStorage : Allow you to store data on the client - side, which can be retrieved later even after the user closes and reopens the browser.
// window.setTimeout() and window.setInterval() : Allow you to execute a function after a specified delay, or at regular intervals.
// window.scrollTo() : Scrolls the window to a specified position.
// window.open() : Opens a new browser window or tab.
// Here is an example of how to use some of these window object properties and methods in JavaScript:
// window.alert("Hello, world!");
// let name = window.prompt("What is your name?");
// let confirmed = window.confirm("Are you sure you want to delete this item?");
// console.log(window.innerWidth, window.innerHeight);
// console.log(window.location.href);
// window.history.back();
// window.localStorage.setItem("key", "value");
// let timer = window.setTimeout(function () {
// console.log("Timeout fired!");
// }, 5000);
// window.scrollTo(0, 0);
// window.open("https://www.example.com");
// By using the window object and its properties and methods, you can interact with the browser window and provide a better user experience for your users.