How to create simple chromeless popup windows

by Michael Bloch
Taming the Beast
Wednesday, 2nd November 2005
 Hate 'em or love 'em; popup and popunder windows are a constant companion during our Internet surfing. But they can be quite useful, especially the chromeless variety.

A chromeless popup window is one that doesn't show the browsers menu or tool bar, but does retain the title bar (for easy closing). Some visitors have so many options on their tool bars that they take up over a quarter of the screen height!

Chromeless popup windows are a great way to deliver list information and extra help for filling in forms without bogging down your pages.

There are many scripts available for creating popups, but sometimes you'll just want something simple that won't require you to incorporate 100 lines of JavaScript!

This particular chromeless popup window procedure will work in Netscape and IE Versions 4+. It will create a link activated window of a fixed size, but will allow for scrollbars if necessary.

Chromeless popup window instructions

First, create and save a standard page with the information you wish to be displayed in the popup window. The elements should be placed within a table structure. Suggested width of table: around 330 - 350 pixels. 

And if you want to create a "Close this Window" statement in the page:

<a href="javascript:self.close()">Close this window</a>

If you choose not to include this snippet, visitors will still be able to close the window via the popup window title bar controls.

Second, the script to launch the chromeless popup window. Copy and paste this into the HTML (between the <body> and </body> tags) of the page you wish to launch the popup from (change the properties in capital letters to suit):

<script>
function openpopup(){
var popurl="PATH TO PAGE YOU CREATED"
winpops=window.open(popurl,"","width=390,height=490,scrollbars,")
}
</script>
<!-- End -->

You can change width and height to suit, but don't make it too narrow, otherwise site visitors will need to scroll horizontally to view the content. Too wide a setting will cover the majority of the screen area for those users still running 640x480 resolution.

When copying scripts like the one above, ensure you paste it into Notepad first; then copy it again and transfer it to your HTML. Copying and pasting code straight from a web page can produce some pretty weird results, especially if you are using Microsoft FrontPage.

Next, the hyperlink to use to engage the script and launch the popup window (Change the properties in capital letters to suit):

<a href="javascript:openpopup()">CLICK HERE</a>

Done!

If you are looking for a script to create an automated site entry or site exit popup or popunder window, check out our related free javascript code generators section.

Use automated popups with caution - I don't know many visitors who upon entering a site and seeing a popup window yell, "whoopeee!!!". Just on that point, you might be interested in reading my article on popups versus popunders for delivering advertising and generating revenue


Options:
Printer Friendly

About The Author:

Visit http://www.tamingthebeast.net for free Internet marketing and web development articles, tutorials and tools! Subscribe for free to our popular ecommerce/web design ezine!

Developer Categories



Developer Tutorials
ASP
CGI & Perl
CSS
Flash
HTML
Java
JavaScript
MySQL
PHP
Python
XML

Developer Documentation

Developer Tools



Search our Developer Tutorials
  The DevSyndicate Network