Click to See Complete Forum and Search --> : close window event for framed popup


asolell
12-28-2002, 07:53 AM
Hi,

I have a 'master' window that makes a dynamic call to a frame popup window.
The popup window is called additional_images_frame.php and has the left side frame called content and main side frame called main.
Left side - Content has the page additional_images_thumbnails.php and the Right side - Main has a page called additional_images_image.php

I want a button/link/image that closes the entire popup window. The link/button/image should be on the left side
of the frame window (part of the additional_images_thumbnails.php

Is it possible?

-Alon.
js@wsco.com

Charles
12-28-2002, 08:09 AM
<script type="text/javascript">
<!--
if (window.opener) {
document.write('<a href="#">Close Window</a>');
document.links[document.links.length-1].onclick = function () {parent.close()}
};
// -->
</script>

That ought to do it.

asolell
12-28-2002, 09:15 AM
Yes!
Thank you!

Just a tiny fix to that code you wrote opener instead of open in the window. event. Once that was fixed, it worked like a charm!
Thanks,

-Alon.


<script type="text/javascript">
<!--
if (window.open) {
document.write('<a href="#">Close Window</a>');
document.links[document.links.length-1].onclick = function () {parent.close()}
};
// -->
</script>

Charles
12-28-2002, 09:24 AM
You've misunderstood. window.opener refers to the window that did the opening. The idea is that you only want this link to be present if the window was opened as a child of some other window. window.open is simply a method of the window object and is always taken to be true.

asolell
12-28-2002, 10:18 AM
You are correct.
I do not fully understand the logic of how this code works.
The popup window is dynamically created, so in effect it cannot be opened directly.
I'm now sure what value is a valid value to enter instead of the opener. The fact the code works now, is good for now,. I would like to understand though how to manipulate it.
Could you give me an example of what values to enter coming from a window called

car_detail.php?Id=2

The way I left the code with open.. does this mean it will work of regardless of the name of the "master' window?
If I specify a name would it limit the code to a specific window?
Thanks,

-Alon.