PDA

View Full Version : Need to Modify a Kirupa Pop-up Tute



will-s
May 29th, 2008, 05:36 PM
Sometime ago, I read Kirupa's Javascript tutorial: "Launching a Centered Pop-Up Window" and used the code to good effect on four buttons on a swf that brought up four different html pop-ups. However, I always had to warn the viewer to manually close each one when finished or clicking on the next one would only bring back the first one.

Now I would like to modify the code so that the first one closes automatically when you click on the second one (etc.)

I've tried making the target_winName the same -- and different -- but neither worked. And I've looked all over the web and in a javascript book, to no avail. I've even tried an on (press) lead-in code sort of like this:
on (press) {
window.close("aaronCreditsActor.html");

that I would apply to each, to "shotgun" the closing the other three. But it doesn't work either.

Any ideas? How about blur()? Thanks.

simplistik
May 30th, 2008, 10:59 AM
ummm if you did it strictly w/ JS you would do something like


<script type="text/javascript">
function openWindow() {
somewindow = window.open("http://www.google.com","somewindow","location=no");
}
</script>



to toggle the window open and close you'd do


<input type="button" onclick="openWindow()" value="Open 'somewindow'" />
<input type="button" onclick="somewindow.close()" value="Close 'somewindow'" />

actionAction
May 31st, 2008, 02:01 AM
In the body tag of your individual popup windows place this code:


<body onblur="javascript:self.close();">

will-s
May 31st, 2008, 02:15 PM
I tried actionAction's onblur solution first and it worked!

(I think simplistik's would have required modifications I would have struggled with.)

Thanks again!!

actionAction
May 31st, 2008, 03:52 PM
No problem!