Click to See Complete Forum and Search --> : closing windows that have been opened with js


rosebudjoy
12-01-2003, 01:25 AM
I am using a javascript to open a pop-up window and I was given this code <body onblur="window.close()">
by ray326 (thanks) to make the pop-up close when clicking off of itself. This seems to only work for Mac users... and it's buggy.
The problem is that I have other links on the pop-up and they are closing when clicked on itself. Here is the link to the site, http://www.christianemillinger.com/

and here is the javascript I am using to open the pop-up...
(click on History to view)

window.open('http://www.christianemillinger.com/welcome/history/','windowname','width=420,height=540,resizable=no,scrollbars=yes,top=1,left=370')

Any help would be deeply appreciated. Thanks.

Gollum
12-01-2003, 03:35 AM
Why is it so important to close the window just because the user clicked somewhere else? As you said the body-onblur is not very reliable and can result in unpredictable behaviour - for example if the user right-clicks on your page the onblur can be called. In other circumstances another popup may appear at any time (e.g. a reminder window or something) and the user may not be too happy if your window goes AWOL.
Usually it is enough just to offer a "Close this window" link or button. Or, if you want to minimise the number of windows you have open, you can control this from your main window by storing the return value from the window.open() call.

rosebudjoy
12-02-2003, 12:11 AM
Thanks for responding. The problem is not that there are too many windows open, the problem is that if you leave one pop-up open and click on another from the main page, then it will pop up in the window that's already open. This is due to the javascripting I'm using (I think)... and I am using the java so that I can control the size and variables of the pop-ups.

Gollum
12-02-2003, 02:05 AM
I see you've used flash to run your main window and that is what is creating the popups.
I'm not familiar with flash myself, but I suspect that the bit where you create the popup windows, you are giving it a name (in javascript, window.open() it is the 2nd argument). If this name is always the same, it will find the browser window of that name and re-use it. If you give each of your popup URLs different names, you will get different windows for each of them. If you use "" (empty string) then you will get a new window every time (even for the same URL).