PDA

View Full Version : Onclick popup AND parent window close?



typhoidtimmy
02-29-2008, 06:34 PM
Ok my problem is rather simple but I am stuck somewhere.

I am trying to make an onclick event where if a person hits a button, a simple popup will enable verifying the action has been taken while simultaneously closing the parent window.

At the very least, I would not mind an alert to show up stating that they have been verified, but I would prefer along the lines of a simple verification popup that conforms to our look and feel.

I know this is probably totally easy but I am having a brain freeze.

jscheuer1
02-29-2008, 07:11 PM
There are lots of pop up scripts. I would recommend one that doesn't actually pop up a window, but rather a division, something from the page itself that was previously hidden and appears to be separate, but isn't. I say this to avoid its being bocked, which can happen in almost any browser if its pop up blocking settings are set high enough.

That part's easy enough, then the next thing, closing the window is an issue because you cannot close a window using javascript if it wasn't opened using javascript. You can fool some browsers into thinking that a window opened normally was opened using javascript, but certainly not all of them.

Now, if this isn't the first page on your site, it is easy enough to make sure it gets opened by javascript.

So, it could all work out. But then, what to do about people without javascript enabled? That's something you should figure out, depending upon how important the content and this confirmation action is, and how available (accessible) you want all this to be. I can help on the details of that, once I know the specifics.

Here's some fairly good fake 'pop up' scripts:

http://www.dynamicdrive.com/dynamicindex8/dhtmlwindow/index.htm
http://www.dynamicdrive.com/dynamicindex17/dropinbox.htm
http://www.dynamicdrive.com/dynamicindex11/abox.htm
http://www.dynamicdrive.com/dynamicindex11/abox2.htm
http://www.dynamicdrive.com/dynamicindex17/stickynote.htm

All of these may be given the look and feel of your site, some may require modification to pop up on demand, rather than onload.

To close the actual window, as I said is easy (though it would need to be integrated properly into your 'pop up'):


window.close();

as I also said, if it was opened using javascript (also fairly easy, but there are many variations, here's the basics):


<a href="whatever.htm" onclick="window.open(this.href);return false;">Whatever</a>