element.blur() method doesn't work when invoked from dialog onload handler




15 years ago
10 years ago


(Reporter: cmelhorn, Assigned: hyatt)


Windows 2000

Firefox Tracking Flags

(Not tracked)



(1 attachment, 1 obsolete attachment)

1.31 KB, text/plain


15 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7b) Gecko/20040316
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7b) Gecko/20040316

In the code sample (attachment to follow), the blur() method is used to remove
the focus from the link <html:a> element when the dialog is opened, for cosmetic
reasons. This worked in Mozilla 1.2.1, but no longer does in 1.7b, 1.6, and
perhaps earlier. I can think of at least two easy workarounds (setting the focus
to another element like the dialog 'accept' button, or using the
"-moz-user-focus: ignore" style specification), but thought this behavior might
be a manifestation of a larger problem.

Reproducible: Always
Steps to Reproduce:

Comment 1

15 years ago
Created attachment 144330 [details]
sample code - dialog window

Comment 2

15 years ago
Created attachment 144332 [details]
sample code - attached as text this time
Attachment #144330 - Attachment is obsolete: true

Comment 3

15 years ago
In 1.5 element.blur() seems to set the focus to the document element, while in
1.7b it sets the focus to null; what I can't tell is when or why this was
changed, or how it might have affected your code. However blurring is ignored
for XUL elements and I expect the intent was that it should be ignored for XUL
documents, so that the behaviour you are seeing may in fact be correct.

Comment 4

15 years ago
Using a delayed command to blur the link by calling setTimeout from the onload
handler as follows,

setTimeout('blurlink()', 100) where blurlink() is defined as

function blurlink(){document.getElementById('home-link').blur();}

seems to work. This implies that the problem with the element.blur() method is
somehow related to being executed in the onload event thread.

Comment 5

15 years ago
Doh! Because focus() doesn't work reliably in onload, dialog uses setTimeout to
set the initial focus after the window is shown. This means that your attempt to
blur the link is futile because it doesn't have the focus yet...

Comment 6

15 years ago
Ah, okay. Is that something that changed between Mozilla 1.2.1 and 1.6?

Comment 7

15 years ago
I don't think the code has changed since 0.9.9...

Comment 8

14 years ago
Setting the selection range on a textbox in the dialog also appears not to work 
when called from an onload method.  Perhaps an additional event should be added, 
an "onactivate," to be called after a window or dialog has finished initializing 
and rendering?
This is an automated message, with ID "auto-resolve01".

This bug has had no comments for a long time. Statistically, we have found that
bug reports that have not been confirmed by a second user after three months are
highly unlikely to be the source of a fix to the code.

While your input is very important to us, our resources are limited and so we
are asking for your help in focussing our efforts. If you can still reproduce
this problem in the latest version of the product (see below for how to obtain a
copy) or, for feature requests, if it's not present in the latest version and
you still believe we should implement it, please visit the URL of this bug
(given at the top of this mail) and add a comment to that effect, giving more
reproduction information if you have it.

If it is not a problem any longer, you need take no action. If this bug is not
changed in any way in the next two weeks, it will be automatically resolved.
Thank you for your help in this matter.

The latest beta releases can be obtained from:
Firefox:     http://www.mozilla.org/projects/firefox/
Thunderbird: http://www.mozilla.org/products/thunderbird/releases/1.5beta1.html
Seamonkey:   http://www.mozilla.org/projects/seamonkey/
This bug has been automatically resolved after a period of inactivity (see above
comment). If anyone thinks this is incorrect, they should feel free to reopen it.
Last Resolved: 13 years ago
Resolution: --- → EXPIRED


10 years ago
Component: XP Toolkit/Widgets: XUL → XUL
QA Contact: shrir → xptoolkit.widgets
You need to log in before you can comment on or make changes to this bug.