0% found this document useful (0 votes)
2 views2 pages

JS Practical 10

This document is an HTML example that demonstrates how to open a new browser window using JavaScript. It includes a button that, when clicked, opens a blank window centered on the screen with specified dimensions. The script calculates the position and size of the new window before opening it.

Uploaded by

Sahil Badhe
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

JS Practical 10

This document is an HTML example that demonstrates how to open a new browser window using JavaScript. It includes a button that, when clicked, opens a blank window centered on the screen with specified dimensions. The script calculates the position and size of the new window before opening it.

Uploaded by

Sahil Badhe
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Practical No : 10

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>Open Window Example</title>

</head>

<body>

<button id="openWindow">Open Window</button>

<script>

document.getElementById('openWindow').onclick = function() {

const width = 400; // Width of the new window

const height = 300; // Height of the new window

const left = (screen.width / 2) - (width / 2); // Center horizontally

const top = (screen.height / 2) - (height / 2); // Center vertically

// Open a new window with specified dimensions and position

window.open(

'about:blank', // URL to open (blank page in this case)

'NewWindow', // Window name

`width=${width},height=${height},top=${top},left=${left}`

);

};

</script>

</body>

</html>
• Out Put

You might also like