How to Create a Pop Up Window (Automatic)

by Andrew McClain

When creating a web page, you may want to create a message that gets readers' attention. One way to do this is with a pop-up window. If used too often, pop-ups can quickly become annoying. However, when applied with restraint, pop-ups are a useful tool for getting your message across. Just remember not to hide the pop-up behind an open browser window. One nice thing about pop-ups is that you do not need to know a lot of coding to create one: just some simple HTML code and Javascript.

1

Create an HTML file in Notepad or other text editor.

2

Paste the following code between the <head> and </head> tags: <script> function show_popup() { var p=window.createPopup() var pbody=p.document.body pbody.style.backgroundColor="yellow" pbody.style.border="solid black 2 px" pbody.innerHTML="Click outside to close this pop-up." p.show(150,150,200,50,document.body) } </script>

3

Replace the attributes with any that you choose. For example, you can replace "backgroundColor" with a different color. You can also replace the border with a more narrow line or a different color.

4

Save the file with an .htm extension.

5

Open the file in Internet Explorer to test the pop-up.

Video of the Day

Brought to you by Techwalla
Brought to you by Techwalla

About the Author

Andrew McClain has been writing since 1994. He has written several articles for various websites and writes user guides and software manuals for several freelance clients. He has a Bachelor of Arts in journalism from the University of Missouri.

More Articles