It should not be modal but it should stay focused regardless of what
happens in the main window (I set a timeout to remove the onblur event
after 10 seconds)..
<html>
<head>
<script language="JavaScript">
window.document.onblur=function() {window.focus();};
</script>
</head>
<body>
Lorem Ipsum
</body>
</html>
window.document.onblur=function() {alert('Blurred');}; produces an
alert saying 'Blurred' when the window loses focus, this shows that
the event is triggered.
Typing window.onblur() in Firebug does bring the window into focus.
Does anybody have any other ideas?
> X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-GB; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14
^^^^^^^
> Can anybody understand why the following code does not work?
> window.document.onblur=function() {window.focus();};
It appears that you are trying to do something which your
underlying OS does not support (and which well-written
applications for your OS should refuse to do)...
http://msdn.microsoft.com/en-us/library/ms646282(VS.85).aspx
| WM_KILLFOCUS Notification
|
| The WM_KILLFOCUS message is sent to a window immediately before it
| loses the keyboard focus.
...
| While processing this message, do not make any function calls that
| display or activate a window. This causes the thread to yield
| control and can cause the application to stop responding to
| messages. For more information, see Message Deadlocks.
--
Cheers,
Ralph
This is an issue for us because of Disabled (Section 508) users. Our
Web App windows need to be able to focus themselves under various
circumstances. This allows blind users etc much easier access to all
of our app windows because screen readers will have access to the
currently focussed window.
IF the Raise or lower windows option is allowed then we can attempt to
spawn a new popup with the same handle and it will refocus the window
but because this is an accessibility feature surely the Raise or lower
windows option should be allowed by default ... it actually makes the
browser more useable.
> As far as I can see windows are not able to focus themselves. The
> config option to Allow scripts to: [ ] Raise or lower windows does not
> appear to make a difference.
In my testing on WinXP, it does make a difference...
A. I find that window.focus() will raise a Firefox window above
other Firefox windows.
B. If another Firefox window has focus, then this Firefox window
gets focus.
C. If a different application has focus, then it does not take the
focus away from that other application (although the Firefox
window is still raised above other Firefox windows).
> This is an issue for us because of Disabled (Section 508) users. Our
> Web App windows
Do I understand it that your scenario has multiple browser windows,
rather than one browser window vs other applications' windows?
> need to be able to focus themselves under various
> circumstances. This allows blind users etc much easier access to all
> of our app windows because screen readers will have access to the
> currently focussed window.
--
Cheers,
Ralph