problem with window.close()

M

Martin Nadoll

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
 
L

L. 'Perfect' Gordon

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
************************************
 
D

Dima Karelich

Martin Nadoll said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,144
Latest member
KetoBaseReviews
Top