Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Closing a window from ASP upon losing focus 2

Status
Not open for further replies.

Ben7777

Programmer
May 21, 2001
4
US
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?

Much thanks,
Ben
 
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=&quot;window.close()&quot;>.

I'm using IE 5.0, Win 2000 Pro w/SP1.

Still no luck with this.

If I could just make the new window &quot;modal&quot;... anyone know how to do that?

Thanks so much!
Ben A.
 
Hi Ben,

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?

hope this helps, Chiu Chan
WebMaster & Software Engineer
emagine solutions, inc
cchan@emagine-solutions.com
 
Thanks again for the help.

Turns out that if I have <body onblur=&quot;window.close()&quot;>, it works sometimes, but not always. However, if I have
<body onblur=&quot;CloseWindow()&quot;> 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.

Thanks again for all the input!

Ben Anderson
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top