0
5.1kviews
Write JavaScript to open a new window when a link on a page is clicked. The new window opened, is closed by placing a button on the window & writing JavaScript code on the Onclick event of the button
1

enter image description here


1 Answer
0
188views

JavaScript New Window Program

<!DOCTYPE html>
<html>
<head>
<title>New Window</title>
<script>
var newWindow;
function openWindow() {
newWindow = window.open("", "newWindow", "width=500,height=600");
newWindow.document.write("<center><h1>Welcome...</h1>");
newWindow.document.write("<h3>This is The New Window</h3></center>");
}
</script>
</head>
<body>
<center>
<a href="javascript:void(0);" onClick="openWindow()">Click here to open the New Window</a><br><br>
<button onclick="newWindow.close()">Close New Window</button>
</center>
</body>
</html>
Please log in to add an answer.