By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,720 Members | 2,185 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,720 IT Pros & Developers. It's quick & easy.

Test if a window or frame is in focus

P: n/a
Is it possible to test if a window or frame is in focus?

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Jan 28 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a


Yes and No, depends, what is the context?
Danny
Jan 29 '06 #2

P: n/a
I have frameset with a navbar in one of the frames.

Popup menus are displayed onmouseover the navbar. The popup menus can be
larger than the frame's height, so scroll bars appear. The script includes
focus() for the navbar frame so that scrolling can be accomplished with the
scroll mouse or the arrow keys without clicking in the frame.

That means, however, that if another window is opened for whatever purpose
over this framed window , if the mouse moves the over the navbar in the now
blurred navbar frame on its way to the new window, the script fires,
bringing the frameset window to the foreground and hiding the new window.

I want to stop this happening if none of the frames in the frameset have
focus. How do I test if none of the frames in the frameset have focus?

"Danny" <da*******@bluebottle.com> wrote in message
news:Ah****************@newssvr25.news.prodigy.net ...


Yes and No, depends, what is the context?
Danny


Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Jan 30 '06 #3

P: n/a
Roger Withnell wrote:
Is it possible to test if a window or frame is in focus?


No.

Focus is considered an event, not a state. Some DOM objects (such as
window, select, input, textarea, button and anchor objects) have a focus
method, but none have a focus property to indicate whether they are
currently 'in focus' or not. The same list of HTML elements have an
onfocus attribute that can be used to specify what happens when an
element gains focus.

Most browsers implement focus for more elements that are specified in
the W3C HTML 4 specification, however the list likely varies from
browser to browser.

You might try tracking focus using the focus event, but I suspect that
will be unreliable.
--
Rob
Jan 30 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.