By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,814 Members | 2,162 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,814 IT Pros & Developers. It's quick & easy.

problem with window.close()

P: n/a
Hello,

i want to close a popup-window with the onBlur eventHandler.

function closeIt() {
setTimeout('window.close()',2000); }

<body onBlur="closeIt()">
html
</body>

Problem:
There is a form on my page, and when a input-field gets focus, body looses
focus and the window closes.
That's not what i want. I want to close the window, if focus goes to another
window or application, but not when someone tries to fill that form.

Any idea for me?
Thanks a lot,
Martin Nadoll
Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
In your closeIt() function, capture event.clientX and event.clientY, and
check if the mouse coordinates are within the window's coordinates and
then close it if appropriate.

I hope this is helpful.
--
************************************
MUSIC24SEVEN
Pioneers of the
'Digital Entertainment Industry'
http://music24seven.com
************************************
"Martin Nadoll" <ma****@nadoll.de> wrote in message
news:bq*************@news.t-online.com...
Hello,

i want to close a popup-window with the onBlur eventHandler.

function closeIt() {
setTimeout('window.close()',2000); }

<body onBlur="closeIt()">
html
</body>

Problem:
There is a form on my page, and when a input-field gets focus, body looses
focus and the window closes.
That's not what i want. I want to close the window, if focus goes to another window or application, but not when someone tries to fill that form.

Any idea for me?
Thanks a lot,
Martin Nadoll

Jul 20 '05 #2

P: n/a

"Martin Nadoll" <ma****@nadoll.de> wrote in message
news:bq*************@news.t-online.com...
Hello,

i want to close a popup-window with the onBlur eventHandler.

function closeIt() {
setTimeout('window.close()',2000); }

<body onBlur="closeIt()">
html
</body>

Problem:
There is a form on my page, and when a input-field gets focus, body looses
focus and the window closes.
That's not what i want. I want to close the window, if focus goes to another window or application, but not when someone tries to fill that form.

Any idea for me?
Thanks a lot,
Martin Nadoll


Use onFocus event in your main window.
If you opened your pop-up window with newWin = window.open(.....) then
in the main window use
<body onFocus="newWin.close()">
Wnen pop-up looses focus the main window gets it - this is my idea how to
fix the problem.
All the best,
Gennadiy


Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.