deadlock Message Board
[ August Full List | Reply ]

Re: Pop Up Windows
From Craig Boas at French Accents Antique Furniture on 12 August '00
replying to Pop Up Windows posted by Richard Jones

>How do I make links on my website, buttons etc, open in a pop up window with no toolbars etc?. I need to know how to do this in both flash and html.

At the top of your page (in between the head tags works well) insert the following code to define the JavaScript function "openWin":

<script language="JavaScript">
<!--hide from non-java enabled browsers
function openWin(name) {window.open(name, 'popup', config='height=300,width=500,toolbar=no,scrollbars=no,resizeable=yes,location=no,directories=no,status=no');}
// end hiding -->

</script>

Next, add the following code where you want the link to the popup window to appear:

<a href="javascript:openWin('privacy.html');">Privacy Policy</a>

Of course you'll need to change "privacy.html" to the name of whatever page you want to appear in the popup window and "Privacy Policy" to whatever link text (or image) you want. You'll probably also need to change the height and width numbers specified in openWin to suit the content you plan to display in the popup window. Make sure you test in 640x480, 800x600, and 1024x768 resolutions and in Netscape Communicator and Microsoft Internet Explorer. This is especially important here because you are depriving the user of scrollbars and the ability to resize the window. As a result, if your content doesn't fit, users won't be able to get to it.

Somewhere in the popup window .html file ("privacy.html" in the above example) you may also want to place the code:

<form><INPUT TYPE="SUBMIT" NAME="closer" VALUE="Close Window" onClick='self.close()'></form>

This is optional, as users will also be able to close the window using their operating system's close window function, but it's a nice touch.

Finally, you should insert the following javascript in the body tag at the start of the popup document:

<BODY onLoad="self.focus()">

This makes the popup window jump to the front of the user's desktop whenever it finishes loading. This is important because users sometimes will open a popup and then click in another window without closing the popup first. When this happens, the popup is obscured by the other window, and if the user clicks another popup, the contents of your popup window will change, but the user won't see it. With this bit of code, the popup will jump to the front every time it changes.

You can see a fully functional example of this code on my site at:

http://www.faccents.com/gallery.html

Hope this helps!

Craig




Reply to this message

Required Details
Your name:
Subject:

Optional Details
Home page title:
Home page URL:
Email:
(if you'd like to receive automatic replies by email)

Your Message