Closed Bug 296469 Opened 17 years ago Closed 16 years ago

Mozilla doesn't implement document.hasFocus like IE

Categories

(Core :: DOM: Core & HTML, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: jdperlow, Assigned: pkasting)

References

Details

(Whiteboard: see also bug 296471)

Attachments

(2 files, 3 obsolete files)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.7) Gecko/20050414 Firefox/1.0.3
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.7) Gecko/20050414 Firefox/1.0.3

IE implements document.hasFocus which provides a reliable way to determine
whether any element in the browser window has focus. Mozilla should have this
too. Some browser applications will behave differently based on whether the page
has focus.

Reproducible: Always
I'm working on a new product that will have a lot of usage. This functionality
is essential to it working well. Would be very happy to see this in FF1.1 so
that the Firefox experience can be at least as good as the IE experience.
Flags: blocking-aviary1.1?
Attached file HTML file using document.hasFocus (obsolete) —
This was taken from
http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/hasfocus.asp
which exemplifies the use of document.hasFocus. It works on IE but doesn't work
for me.
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.8) Gecko/20050511
Firefox/1.0.4
This is the same file with a very simple modification that replaces
document.hasFocus. Something a little more robust might be necessary for a
decent workaround, but this works.
That workaround doesn't work if there are nested iframes in the page. If a
nested iframe has focus, the workaround doesn't return the right value. In IE,
document.hasFocus() returns true if anything nested in the document has focus,
including content inside iframes.
Flags: blocking-aviary1.1? → blocking-aviary1.1-
Assignee: general → pkasting
Status: UNCONFIRMED → NEW
Ever confirmed: true
Whiteboard: see also bug 296471
Attached patch patch v1 (obsolete) — Splinter Review
This seems to do the right thing as far as I can tell.  Testcase files to be attached shortly.
Attachment #224139 - Flags: superreview?(bzbarsky)
Attachment #224139 - Flags: review?(bryner)
Attached file Testcases
Unzip this .tgz file somewhere.  test.html is a simple test based on the test already attached to this bug.  test1.html and test2.html are more complex tests that we get the proper behavior with nested iframes.

In all cases, mousing over the "mouse over me" text should display a message iff that document or any children have focus.
Attachment #185720 - Attachment is obsolete: true
Attachment #185723 - Attachment is obsolete: true
I'd really prefer that someone more familiar with focus than I looked at this... but in any case, you need to change the IID of the interface and please add at the end, not in the middle?
OK, I can change it.  The reason I didn't change it was because the last couple of additions to that file hadn't changed it, but maybe I was looking in the wrong place or something.
Attached patch patch v2Splinter Review
Address bzbarsky's comments.
Attachment #224139 - Attachment is obsolete: true
Attachment #224142 - Flags: superreview?(bzbarsky)
Attachment #224142 - Flags: review?(bryner)
Attachment #224139 - Flags: superreview?(bzbarsky)
Attachment #224139 - Flags: review?(bryner)
This patch is included (in a slightly modified form) inside the patch I just attached to bug 337631, with the same reviewers.
Blocks: 296471
Comment on attachment 224142 [details] [diff] [review]
patch v2

removing this review since the patch is folded into bug 337631
Attachment #224142 - Flags: review?(bryner)
Comment on attachment 224142 [details] [diff] [review]
patch v2

In that case I'll remove the SR request as well.
Attachment #224142 - Flags: superreview?(bzbarsky)
FIXED by the commit of bug 337631 to the trunk.
Status: NEW → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
Component: DOM: Core → DOM: Core & HTML
QA Contact: ian → general
You need to log in before you can comment on or make changes to this bug.