Open
Bug 554039
Opened 14 years ago
Updated 2 years ago
Main window won't get focus after it was granted to an iframe. window.top.focus() doesn't work
Categories
(Firefox :: General, defect)
Tracking
()
NEW
People
(Reporter: lukasz.olejnik, Unassigned)
References
()
Details
(Keywords: access, regression, testcase)
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; pl-PL; rv:1.9.2.2) Gecko/20100316 Firefox/3.6.2 Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; pl-PL; rv:1.9.2.2) Gecko/20100316 Firefox/3.6.2 Starting from FF 3.6 (regardless of the system on which it runs) I've noticed that after one of my scripts moves focus to an iframe (like: window.top.frames[1].focus()) it is unable to bring the focus back to window.top (with window.top.focus()) I've demonstrated this issue here: http://www.8sec.eu/focus-test/ Reproducible: Always Steps to Reproduce: 1. Open this page: http://www.8sec.eu/focus-test/ 2. Click on the gray bar with 'Click here to start the test!' message 3. Hit the space bar when the message in that box tells you. 4. Continue until my scripts will try to reassign focus to the window.top again. Actual Results: window.top doesn't get focus after one of its frames received it Expected Results: window.top to be able to get focus back from one of its iframes with window.top.focus()
Comment 1•14 years ago
|
||
Confirmed with Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.3a4pre) Gecko/20100321 Minefield/3.7a4pre Is probably a regression from bug 178324.
Comment 2•14 years ago
|
||
So it seems that window.focus() also clears the focus in that window in other browsers, although Safari only does so if the window isn't already focused.
Build worked : Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2a1pre) Gecko/20090610 Minefield/3.6a1pre http://hg.mozilla.org/mozilla-central/rev/90d3e6d2cbb9 Build Broken : Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2a1pre) Gecko/20090611 Minefield/3.6a1pre http://hg.mozilla.org/mozilla-central/rev/4430cae50dad Pushlog : http://hg.mozilla.org/mozilla-central/pushloghtml?fromchange=90d3e6d2cbb9 &tochange=4430cae50dad
Comment 4•13 years ago
|
||
I have found the same issue in opening a child window and then having the child window attempt to bring it's parent back into focus.
Comment 5•13 years ago
|
||
There is a hacky workaround for this, where you create an input element on window.top or window.parent and focus that before removing the input element from the DOM. While this does allow you to focus the parent from a child, at least with an iFrame child, it is far less clean that just being able to window.parent.focus() from a child. It may be desirable to limit the ability for a child window to focus on it's parent when the child is a true window or tab, but I don't see any value in this limitation for the purposes of iFrames.
Comment 6•12 years ago
|
||
It looks like the link to the original description is broken. However, you can reproduce the problem with FF 12 and this js-fiddle: http://jsfiddle.net/paleozogt/cXW4e/
Comment 7•12 years ago
|
||
This behavior becomes a real problem when you combine it with bug 706209. That is, we could work around the inability to change the active window by setting the inactive window's selection color, but 706209 prevents that. For more info see these discussions: http://stackoverflow.com/questions/10501381 http://stackoverflow.com/questions/10502099
Comment 8•10 years ago
|
||
I was just notified that this prevents the Google Hangouts team from making Hangouts more accessible. The description I received was: "There is an issue with Hangouts within Gmail that only affects the Firefox browser (this works fine in IE, for instance), in which activating the "q" keyboard shortcut doesn't place focus in the Hangouts search field." Is there some way we can start acting on this admittedly old issue?
Flags: needinfo?(enndeakin)
Keywords: access
Comment 9•10 years ago
|
||
Well you can always just blur the child frame instead. In fact, if your goal is to focus the parent frame instead of the child frame (and not change the toplevel window stacking order), this is a better way to do it and not call window.focus() at all: frameElement.blur() The testcase no longer works so I can't tell for sure.
Flags: needinfo?(enndeakin)
Comment 10•10 years ago
|
||
Thanks Marco and Neil! I am software engineer from Google Hangouts team. Actually the problem we met is the reverse: when the focus is on the main window, we can't focus on an element in an iframe directly. What I did is to focus on the iframe firstly and then focus on the element, it works! I think it is the same solution as Neil's suggestion. Thank you guys!
Updated•2 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•