473,327 Members | 1,997 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

onblur not working in firefox

Jezternz
145 100+
Okay, ill post a bit of my code, keep in mind theres alot more.
Not necessarily a firefox bug, but its not doing what I want it too :)

This is for a dropdown, however I would appreciate help with the problem, Im not looking for input on how else to do the dropdown, ect.

Expand|Select|Wrap|Line Numbers
  1. TBTool.prototype.DropDownActivate = function()
  2. {
  3.     var place = findPos(this.thetool);
  4.     this.dropout.style.display = "block";
  5.     this.dropout.style.left = place[0]+"px";
  6.     this.dropout.style.top = (place[1]+29)+"px";
  7.  
  8.     this.dropout.focus();
  9.  
  10.     var that = this;
  11.     var handler = function(e) {
  12.            that.DropDownDeactivate.apply(that, arguments);
  13.     };
  14.     window.addEventListener?
  15.      this.dropout.addEventListener('blur',function(){alert('hi')},false)
  16.       :this.dropout.attachEvent('onblur',handler);    
  17.  
  18. }
  19. TBTool.prototype.DropDownDeactivate = function()
  20. {
  21.     this.dropout.style.display = "none";
  22. }
  23.  
Couple of things to note, first of all this is OOP.
Secondly "this.dropout" is an element on the page.

Anyway for some reason the event is fired (onblur) in IE but not in Chrome or FF? any ideas?

Thanks in advance, Josh
Dec 9 '08 #1
25 12925
acoder
16,027 Expert Mod 8TB
You'll have to post the rest of your code or a link. I tested your code and it works fine in FF3.
Dec 9 '08 #2
Jezternz
145 100+
Edit: Nevermind heres a link
The Site or Web app:
http://www.gcstore.co.nz/example.htm [Warning: may cause crash if using IE]
Javascript (the main one but there are several more pages)
http://www.gcstore.co.nz/wds/toolbar_class_methods.js

but yeh view in ie and ff :)

thanks
Dec 9 '08 #3
acoder
16,027 Expert Mod 8TB
That explains it. I thought you were talking about a drop down select element (which is what I tested with). With most elements, Firefox and probably most browsers, the blur event isn't defined. See this link.

Either use the focus of other elements, or use the click event of the editor window.
Dec 9 '08 #4
Jezternz
145 100+
ok, thanks acoder, any constructive critism or ideas for my editor so far?

Also you say the blur event isnt defined by most elements, does this mean that the onfocus is defined in most elements?
Dec 9 '08 #5
acoder
16,027 Expert Mod 8TB
Yes, the same applies to onfocus. See https://developer.mozilla.org/en/DOM/element.onfocus.

I've not really had a play with the editor, but from what I saw, it looks nice.
Dec 9 '08 #6
Jezternz
145 100+
oh, I havent done much on it, alot of work to do :), I meant ideas for features / ways I can do things, and all that, but ill post back here if I come across any other problems / obstacles, im sure I will
Dec 9 '08 #7
gits
5,390 Expert Mod 4TB
another option could be the onmouseout-handler ... combined with some focus-events for other nodes - it could be a bit tricky when it comes to different possibilities on how the user might use the interface (mouse/keynavigation/both)

kind regards
Dec 9 '08 #8
Jezternz
145 100+
yeh I did wonder about that gits.
For now what im thinking of doing is using the main object (I called it WDS for WebDesignScript) and making a variable, which will contain what I dictate is currently selected or "foccused" anyway, also have a reference to a function or method that will shutdown whatever is selected at the time. then when something else is focussed, it will run that shutdown method/function, then overwrite it with a new var + method/function reference and so on and so forth.

Just an idea though :)
Dec 9 '08 #9
tomaz
29
i opened your site and my pc crashed :)

I only clicked the link 'click here to open'
Dec 9 '08 #10
rnd me
427 Expert 256MB
@tomaz
i was able to force-close IE with task manager before i suffered the same fate...
Dec 9 '08 #11
tomaz
29
yes yes Yezternz

you like unfinished loops? :)
Dec 9 '08 #12
Jezternz
145 100+
Would someone be able to enlighten me as to where this is, thats pretty horrible, and I have done extensive testing, but only in the limited area of my specific versions of IE (7.0.6001.18000), FF (3.0.4) and Chrome (0.4.154.29). I Originally was making this with the intention of giving support to IE6, however because the script will end up so massive, I thought it better to just make it a requirement to either update your browser or switch to ff/ch. So im guessing you guys were using ie6? mabey? I should really stick in a block to all lower browsers. If it was ie7, I think i need help with this, cause mine works fine :(

I apologize for the crash's.

Josh

edit: Would one of the moderators be able to edit my post with the links, and add a warning or something, or even remove them would be helpful.
Dec 9 '08 #13
drhowarddrfine
7,435 Expert 4TB
Someone who I can't name once told me this:
The standards say that onblur and onfocus are only valid for form elements and <a> tags. Where they work anywhere else at all it is non-standard and browser specific.
The W3C standard says about 'onfocus':
This attribute may be used with the following elements: A, AREA, LABEL, INPUT, SELECT, TEXTAREA, and BUTTON.
Dec 12 '08 #14
Jezternz
145 100+
thats strange I tried changing the code from a div to an a, and then netiher ie or ff allowed the onblur event to work :(
Dec 16 '08 #15
drhowarddrfine
7,435 Expert 4TB
Your link doesn't work.
Dec 16 '08 #16
Jezternz
145 100+
yes your right my web server seems to be down atm. Anyways I ditched the <a> idea and I have successfully got one of the previous ideas working. The one where it closes the toolbar dropdowns on the event "onclick" on the other elements on the page. However, this does not work in firefox :(, the onclick does not work on my middle element (which has an iframe in it), so I tried changing the event to an "onfocus" event on the iframe, it worked perfectly in ie, still no luck in ff. I will upload latest version when server goes back up. Also is there such events as "onChildFocus" or "onChildClick", would be helpful though I am doubtful. If anyone has any more ideas on how to do this, that would be great.

Thanks, Josh
Dec 16 '08 #17
acoder
16,027 Expert Mod 8TB
onfocus is not supported for the iframe, but you can use the document inside, i.e. the contentDocument. See if that works.
Dec 16 '08 #18
Dormilich
8,658 Expert Mod 8TB
what about some CSS using for the dropdown (namely the hover pseudo class)? like in the suckerfish dropdowns.

regards
Dec 16 '08 #19
Jezternz
145 100+
that is actually a very good idea, I will look into that :)
Dec 16 '08 #20
Jezternz
145 100+
I looked for a couple of hours and behold! there is a way to make divisions use onblur in firefox!
Its actually very simple too.

Expand|Select|Wrap|Line Numbers
  1.     div_element.setAttribute("tabindex","-1");    
  2.     div_element.style.outline = "none";
  3.  
This seems to work and look great!

Thanks for your suggestions, im happy I ended up getting it working exactly how I wanted!

Cheers, Josh
Dec 17 '08 #21
acoder
16,027 Expert Mod 8TB
Hmm. Interesting solution. Dormilich's idea is good as long as you're using links. If you're using anything else, IE6 and IE7 Quirks mode don't understand :hover.
Dec 17 '08 #22
Dormilich
8,658 Expert Mod 8TB
therefore the suckerfish developers made a workaround for that (basically a javascript that writes/removes a class that applies :hover's CSS)
Dec 17 '08 #23
Jezternz
145 100+
Is there a way to edit an elements :hover from javascript, cause that could work.
Dec 17 '08 #24
acoder
16,027 Expert Mod 8TB
@Dormilich
Yes, I forgot that they did that. That would normally be the way to support it in those browsers or an HTA.
Dec 18 '08 #25
acoder
16,027 Expert Mod 8TB
@Jezternz
There's no need for that. As Dormilich pointed out, you just need to use some JavaScript to use onmouseover/onmouseout for the same effect as explained here.
Dec 18 '08 #26

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Roger Withnell | last post by:
Tearing hair out time! Simple attached page shows the problem. http://www.brilley.co.uk/TestFocusSelect.htm Using a function to test if too many characters have been keyed in to a textarea....
6
by: rob | last post by:
Hi I'm trying to create a "roll-up" effect when a window loses focus and then "roll-down" when it regains focus. This statement works properly with every browser I can get my hands on EXCEPT...
4
by: Peter Pagé | last post by:
Hi, I've got a window with a "<body onBlur="window.close()"> tag that keeps closing prematurely. It happens when the user clicks on text inside a table in the same window. Apparently IE...
1
by: clemtig | last post by:
Say I have a form with two input textfields. Each has an onFocus and onBlur. onFocus will unhide image #1. onBlur will hide image #1, show image #2 and validate the textfield. But the problem is that...
3
by: rjones326 | last post by:
Hi, I'm stupendously mystified by this strange activity. I cannot for the life of me figure out why this will not work in mozilla. I've spent hours mucking around with it. The php file is...
2
by: Mathias Fritsch | last post by:
I try to run the following code, but no onblur/onfocus events happen. Is onfocus/onblur implemented in ie/firefox? <html xmlns="http://www.w3.org/1999/xhtml"> <head> </head> <body> <form>...
10
by: John Kotuby | last post by:
Hello all... I am working on an ASP.NET 2.0 application with VS2005 and VB. I have chosen to use popup windows in some cases because it makes the user experience better (according to all the users...
2
by: Jeff | last post by:
I've now searched the web for about 2+ hours and have found dozens of solutions, but none work. All information seems outdated and won't apply to Firefox 2.0. I'm trying to create the equivalent...
2
by: wolverine | last post by:
Hi All, In Mozilla Firefox, to onblur and onfocus event of each and every html element, the browser itself will attach a native event handler. I mean if you type,...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.