D. Alvarado wrote:
I'm having some trouble with the "onBlur" event in the BODY tag.
Ideally, what I want to happen is that when someone leaves window A,
window A executes a command. I had put
<body onBlur="savePage();">
I have a couple of problems. On IE 6 (win2000), whenever I put the
cursor focus on a textfield within window A, the "savePage" function
is invoked. And on Mozilla Filefox 0.9.1, the event never launches
even when I leave the window.
For Mozilla you might want to use
window.onblur = function (evt) {
savePage();
}
that should work with IE too but of course the original problem is not
solved by that, namely that exactly one object can have the focus
meaning when you focus on some object in the window the window looses
focus and thus the onblur handler is called. One way to try to work
around that is to have
var tid;
window.onblur = function (evt) {
tid = setTimeout('savePage();', 20);
}
and then to make sure that every element in the page that can get the
focus cancels the timeout e.g.
<input type="text" onfous="clearTimeout(tid);">
--
Martin Honnen
http://JavaScript.FAQTs.com/