I have some ASP code that pops up a window with a calendar in it. I need to automatically close that calendar window when it loses focus. How might this be accomplished?
First, I'm not sure that u can close a window without getting an annoying prompt asking if closing the browsers really what you want to do.. its a built in security feature.
Did u want to trap when the window or the calendar loses focus?
Thanks for the reply! I tried the onblur idea, but for some reason the onBlur event is not firing when the window loses focus - only when some control on it loses focus (I think)... when I click one of the calendar buttons the onBlur fires, but I have the onBlur in the body, like <body onBlur="window.close()">.
I'm using IE 5.0, Win 2000 Pro w/SP1.
Still no luck with this.
If I could just make the new window "modal"... anyone know how to do that?
can you post on the web? or show us some of your code?
cuz i never have this kind of problem before, maybe there is another javascript error occurs so it stop the onblur event?
Turns out that if I have <body onblur="window.close()">, it works sometimes, but not always. However, if I have
<body onblur="CloseWindow()"> and then do a window.close() inside the CloseWindow() function, it works every time. Wierd. The scenario where it is sporatic is this: Have a button that does a window.open(...). That window has the onblur event to fire window.close(). Just keep clicking the button without moving the mouse... sometimes the window.close() works in the child window and sometimes it doesn't. But with CloseWindow() as the onblur function, it seems to work every time. Maybe it's some kind of strange timing issue with the events.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.