I have a strange problem and hope that somebody can help me.
There are two pages: main.jsp and popup.jsp
Main.jsp contains a button. When you click the button, it calls a popup (popup.jsp) by using the window.open method.
I want to ensure that you can not do anything on the main.jsp as long you do not close the popup.
Therefore I use this JavaScriopt code in the main.jsp:
- Code: Select all
window.onfocus = closePopup;
if (popup!= null && popup.closed == false)
shallThePopUpBeClosed = confirm('Do you really want to close the popup?');
if (shallThePopUpBeClosed == true)
// This is called when you click on the button to open the popup.
popup = window.open('popup.jsp', 'PopupWindow', 'height=350, width=800, scrollbars=no, toolbar=no, resizable=no,left=150, top=200');
This works in 90% of all tests.
But sometimes it does not work... the onfocus event seems to be ignored (I tested it with an alert('test')in the function closePopup() and in those 10% of the tests it is not called).
The strange thing is, that it seems to be a random problem... it appears sometimes after the 1st try... sometimnes after then 20th try. It is really random.
What may be the reson?
A bug in Internet Explorer?
A timing problem of the event onfocus?
Thanks for any hint!
I am using Windows 2000 SP4 and Microsoft Internet Explorer 6.0 SP1.