Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

How to fix the onfocus event in firefox.

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am creating a website, for that onfocus event is not properly working in "Mozilla Firefox".

How can I fix it?

My browser details :

Name : Mozilla Firefox

Version : 32.0
 
Bartender
Posts: 1810
28
jQuery Netbeans IDE Eclipse IDE Firefox Browser MySQL Database Chrome Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please TellTheDetails. "not properly working" doesn't give us enough information. What do you expect it to do and what is doing or not doing? Have you tried using a console.log message to see if the event is properly bound to the element? Show us some code.
 
Sasikumar Senthilnathan
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My Code is :

HTML Code:


JavaScript Code:



The textbox loses its focus once I press tab.
 
J. Kevin Robbins
Bartender
Posts: 1810
28
jQuery Netbeans IDE Eclipse IDE Firefox Browser MySQL Database Chrome Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So it appears that what you are trying to do is prevent the user from leaving the text field if they don't enter a name, by returning the focus to that element, correct? Does the alert box appear?

Try changing your code like this and tell us what you get.
 
Marshal
Posts: 67451
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This:is not doing what you think it is doing.

Hint: think about whether you want to call the focus() method of the element, or the focus() method of the jQuery wrapped set (which do not do the same thing).
 
Sasikumar Senthilnathan
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But the same code is perfectly working in Google Chrome Browser....
 
Bear Bibeault
Marshal
Posts: 67451
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can argue, or you could try to fix the problem. Something that's incorrectly coded but accidentally works is not complete.
 
J. Kevin Robbins
Bartender
Posts: 1810
28
jQuery Netbeans IDE Eclipse IDE Firefox Browser MySQL Database Chrome Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Sasikumar Senthilnathan wrote:But the same code is perfectly working in Google Chrome Browser....


That's because there are variations in how different browsers implement the standards. Some are more forgiving of mistakes, while others adhere very strictly to the standards. You should aim to have your code work in all browsers or else it's likely to break with the next browser release.

Just for fun sometime, do a Google search for the phrase "works in firefox but not ie" and see how many different problems there are.
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic