javascript_6
javascript_6
Experiment no 13 F
Program :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-
scale=1.0">
<title>DOM, Popovers, and Window Operations</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
text-align: center;
}
.popover {
display: none;
position: absolute;
padding: 10px;
background-color: #f8f9fa;
border: 1px solid #ddd;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
border-radius: 5px;
}
button {
padding: 10px 20px;
font-size: 16px;
margin: 10px;
}
#dynamicContent {
margin-top: 20px;
}
</style>
</head>
<body>
<h1>DOM Manipulation, Popovers, and Window Operations</h1>
<!-- Button to open a popover -->
<button id="popoverButton">Show Popover</button>
<script>
// DOM Manipulation Example
// Add content dynamically to the page
const dynamicContentDiv =
document.getElementById('dynamicContent');
dynamicContentDiv.innerHTML = '<p>This content was added
dynamically via JavaScript!</p>';
// Popover functionality
const popoverButton = document.getElementById('popoverButton');
const popover = document.getElementById('popover');
const closePopoverButton =
document.getElementById('closePopover');
openWindowButton.addEventListener('click', function() {
const newWindow = window.open('', 'NewWindow', 'width=500,
height=400');
newWindow.document.write('<h1>Welcome to the new window!
</h1>');
newWindow.document.write('<p>This content is dynamically
added using JavaScript in a new window.</p>');
});
</script>
</body>
</html>
OUTPUT :