-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path7bb.html
More file actions
59 lines (59 loc) · 1.83 KB
/
Copy path7bb.html
File metadata and controls
59 lines (59 loc) · 1.83 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
<!DOCTYPE html>
<html>
<head>
<title>Window Object Properties and Methods</title>
</head>
<body>
<h1 id="heading">Window Object Properties and Methods</h1>
<button onclick="openWindow()">Open Window</button>
<button onclick="closeWindow()">Close Window</button>
<button onclick="moveWindow()">Move Window</button>
<button onclick="resizeWindow()">Resize Window</button>
<button onclick="alertMessage()">Alert Message</button>
<button onclick="confirmMessage()">Confirm Message</button>
<button onclick="promptMessage()">Prompt Message</button>
<script src="7b.js"></script>
</body> </html>
JavaScript File (script.js)
// Get the width and height of the window
console.log("Window Width: " + window.innerWidth);
console.log("Window Height: " + window.innerHeight);
// Function to open a new window
function openWindow() {
let newWindow = window.open("", "newWindow",
"width=400,height=200");
newWindow.document.write("<h1>Hello, World!</h1>");
}
// Function to close the current window
function closeWindow() {
window.close();
}
// Function to move the current window
function moveWindow() {
window.moveBy(100, 100);
}
// Function to resize the current window
function resizeWindow() {
window.resizeBy(100, 100);
}
// Function to display an alert message
function alertMessage() {
window.alert("Hello, World!");
}
// Function to display a confirm message
function confirmMessage() {
let response = window.confirm("Are you sure?");
if (response) {
console.log("You clicked OK!");
} else {
console.log("You clicked Cancel!");
}
}
// Function to display a prompt message
function promptMessage() {
let name = window.prompt("What is your name?");
if (name) {
console.log("Hello, " + name + "!");
} else {
console.log("You did not enter your name.");
} }