Posted on 2002-07-22
How to close a window unconditionally when opening another window.
I have the following script on my index.htm page. The assumption is that the user's screen is 800 resolution width, and an alternative index page called index1024.htm is loaded in a new window if the user's screen resolution width is detected as 1024. This allows me to have a properly designed set of pages for 1024 resolution as well as for the 800 resolution screen.
if (screen.height >= 768 && screen.width >= 1024)
Problem: If and when the user closes the 1024 Window, the original 800 resolution window becomes visible from behind the 1024 window. Is there any way that I can force this 800 resolution window to be closed automatically when the 1024 resolution window is opened?
I have tried putting the following code before the window.open line:
This works but not unconditionally. It makes IE present the user with a question to answer, which I would rather did not happen: "The web page you are viewing is trying to close the window. Do you want to close this window? Yes/No"