popup window blur event

L

lazar

I'm triing to write script that close popup window, when user click
outside the popup.

Script below is working fine in firefox (v1.0.3), but not in IE.

I tried also to print hello but still the same problem firefox OK IE
not.
I think the problem is in event capture, but I can't fix it.

My script:
fotowin = window.open("", "foto", "width =100,height
=100,location=no,menubar=no,directories=no,toolbar=no,scrollbars=no,resizable=no,status=no");

fotowin.onblur = closeWin;
if (fotowin.captureEvents) {
fotowin.captureEvents(Event.BLUR);
}

function closeWin() {
fotowin.close();
//fotowin.document.write("hello");
}

thanks for your help.
 
A

ASM

lazar said:
I'm triing to write script that close popup window, when user click
outside the popup.

Script below is working fine in firefox (v1.0.3), but not in IE.

I tried also to print hello but still the same problem firefox OK IE
not.
I think the problem is in event capture, but I can't fix it.

the popup has to set its own onblur
(sometimes it does work also with IE)

Do not remenber if onblur must be in a js script (in head)
or simply in body tag ?
(one of both won't work)
My script:
fotowin = window.open("", "foto", "width =100,height
=100,location=no,menubar=no,directories=no,toolbar=no,scrollbars=no,resizable=no,status=no");

fotowin.onblur = closeWin;

I do not think that is possible

on my idea : fotowin.onblur
means you give to the popup a function (or event) 'onblur'
doesn't mean main window looks for 'does fotowin loose the focus?'

or at least doing :

fotowin.onblur = Function ('self.close();');

You can't attach to the onblur of popup the function closeWin()
belonging to the opener ...
except this way (not tested) :

fotowin.onblur = opener.closeWin;

but you can do its inverse
if main window (the opener) gets back focus hop! close popup

<body onfocus="if(!(fotowin) || fotowin.closed) '';
else fotowin.close();">
 
L

lazar

but you can do its inverse
if main window (the opener) gets back focus hop! close popup

<body onfocus="if(!(fotowin) || fotowin.closed) '';
else fotowin.close();">

After to many hours of triing and googling, find out that there is no
way to set onblur action (that work in IE) for child window. So decided
to do it inverse(thanks ASM).

Good example how to handle mouse events
http://www.chipchapin.com/WebTools/JavaScript/example3-01.html
, but not for blur :(
 

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,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top