postheadericon 9. Write a JavaScript to show a pop up window with a message Hello and background color lime and with solid black border.

Note : Only Internet Explorer support the method window.createPopup(); 


Solution : 1 (Popup)



<html>
<head>
<title>EX-9: WTAD : www.bipinrupadiya.com</title>
<script type="text/javascript">

// createPopup() supported by IE only
function show_popup()
{
var p=window.createPopup();
var pbody=p.document.body;
pbody.style.backgroundColor="lime";
pbody.style.border="solid black 5px";
pbody.innerHTML="<h1> HELLO</h1><br><br><br><br>Click outside the pop-up to close.";
p.show(150,150,400,200,document.body);
}
</script>
</head>

<body>
<input type="button" value="click me" onclick="show_popup()" >
</body>

</html>





Solution : 2 (Window)



<html>
<head>
<title>EX-9: WTAD : www.bipinrupadiya.com</title>
</head>
<script type="text/javascript">
function show_popup()
{
myWindow = window.open("", "mywindow", "width=300,height=100,border:2px solid #ffffff;");
myWindow.moveTo(400, 400);
myWindow.document.write('<h1>HELLO!</h1>');
myWindow.document.bgColor = "#BFFF00";
}
</script>
<body>
<input type="button" value="click me" onclick="show_popup()" >
</body>
</html>

3 comments:

Kale Co Jakim said...

great article

Kale Co Jakim said...

The example demonstrates two approaches to creating a popup in JavaScript. The first uses window.createPopup() to create a styled popup with a lime background, solid black border, and “HELLO” message, while the second uses window.open() to create a separate browser window and set its background color. A Javascript Online Course can help learners understand these browser APIs along with modern JavaScript techniques.

Kale Co Jakim said...

The comparison is also useful for showing how browser-specific methods can differ from more general window-handling approaches. The example clearly notes that createPopup() is supported only by Internet Explorer, while the second solution demonstrates a different way to open and populate a browser window. Practicing small exercises like this can strengthen understanding of JavaScript functions, events, DOM manipulation, and browser APIs through Javascript Online Training.

Blog Archive

Total Pageviews

© BipinRupadiya.com. Powered by Blogger.