window blur event in ie when focus isn't lost

N

nutso fasst

Perhaps this will be useful to someone...

I have a page with a document.onkeypress handler that uses
window.onblur/onfocus events to stop/start an interval timer. In IE 5,
clicking on a DIV with CSS 'position: absolute' fires a window.onblur event.
Subsequently clicking outside the DIV won't fire the window.onfocus event.
If I switch to another window and then back to the window in question, the
onfocus event fires, but the onblur event fires immediately after.
Consequently, neither the interval timer nor the keypress handler will
restart without a page reload.

The fix for this is to add an onfocus handler to the DIV element:

<div onfocus="this.blur()">

The likelyhood of someone accidently clicking on the DIV may be low, but
folks do sometimes click a visible portion of a window to give it focus and
I don't want any of them getting frustrated.

nf
 

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,994
Messages
2,570,223
Members
46,815
Latest member
treekmostly22

Latest Threads

Top