SitePoint Sponsor |
|
User Tag List
Results 1 to 3 of 3
Thread: Mozilla blur() problem
-
Dec 19, 2003, 13:42 #1
- Join Date
- Nov 2003
- Location
- Maryland
- Posts
- 28
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Mozilla blur() problem
Please take a look at this page:
http://home.comcast.net/~delerious1/index10b.html
There is javascript code that is executed when the page is loaded. The code
calls the focus() method and then the blur() method on the first anchor in the
box. In IE and Opera the code works. But in Mozilla, you can see the dotted
line around the first anchor, so it's as if the blur() method is not working.
Anyone know what's going on?
-
Dec 19, 2003, 15:40 #2
- Join Date
- Mar 2002
- Location
- Manchester, UK
- Posts
- 853
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
A couple of things. Firstly, your style element should be in the <head>, not the <body>.
On to the real problem:
If I take the "break;" out, and add an alert(i) call inside the if statement, it becomes clear what's happening: only the very first call to focus() or blur() is actually doing anything. Subsequent calls in the same function are ignored. Since this happens to be the "focus" call on the first link, the page gets stuck like that.
I've had a good dig in bugzilla, and I can't find any likely looking bugs. You might have found a new one
This might be a "feature", intended to guard against nasty infinite recursion of onblur/onfocus events (which has been a problem in the past - there are several resolved crash bugs in there that describe this phenomenon)
I have to ask, why are you doing all this focussing and blurring anyway?
[thinks]
Here we go: a quick-and-dirty hack that seems to fix things in mozilla by playing on its quirks. Change the fixbug function to this:
Code:function fixbug() { var submenu = document.getElementById('submenu'); for (var i=0; i<submenu.childNodes.length; i++) { // check for an anchor, since some nodes are named '#text' if (submenu.childNodes[i].nodeName.toUpperCase() == 'A') { submenu.childNodes[i].blur(); submenu.childNodes[i].focus(); submenu.childNodes[i].blur(); break; } } }
gav
http://www.livejournal.com/users/blufive/
browser stats analysis and comment:
http://www.livejournal.com/community/stats_weenie/
-
Dec 19, 2003, 16:14 #3
- Join Date
- Nov 2003
- Location
- Maryland
- Posts
- 28
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi blufive, thanks for the reply, your fix works!
Hahaha, you must be wondering what the point of that focusing and blurring is...
Well, it's to fix another bug in IE:
http://www.sitepointforums.com/showthread.php?t=143927
Bookmarks