Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

focus() not working in firefox

 
Rakesh Kurup
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Could you please help me to resolve the issue with firefox & safari browser. The issue is javascript focus() function on document object is not working in FF n safa.., but its working fine in IE.

Thanks.
 
vidya lakshmi
Greenhorn
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For firefox how you have used whether like this,

[code}
document.getElementById()
[/code]

Please just mention how you have called the javascript and what you have done? Then only we can give a correct solution.

Regards,
vidya
 
Rakesh Kurup
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
excactly document.getElementById('id').focus();
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And what type of element is this thing you are trying to focus?

Eric
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64171
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Rakesh MR", please check your private messages for an important message from me.
 
Rakesh Kurup
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
its a DIV <div id='id1'>
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well a div does not have a focus method. That is your problem.

You want to bring it into view? http://radio.javaranch.com/pascarello/2005/01/09.html

Eric
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64171
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Rakesh MR", My request that you change your display name to adhere to JavaRanch standards was not a suggestion. Valid display names are mandatory for participation on the Ranch. Please change your display name as instructed prior to your next post.

Be aware that accounts with invalid display names are disabled.

bear
JavaRanch Sheriff
 
Rakesh Kurup
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My center content of the page is divided into two sections(both are scollable). I need to focus the right section element(div) when I select an element(div) from left side. Now focus is not coming to the corresponding sections in firefox but its fine in IE.

I am using document.getElementById(id).focus()

pls provide/suggest solution for this prob.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64171
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Rakesh Kurup:
pls provide/suggest solution for this prob.
Please use real words when posting to the forums. Abbreviations such as "pls" in place of "please" only serve to make your posts more difficult to read and less likely to generate useful responses.

Please read this for more information.

thanks,
bear
JavaRanch sheriff
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64171
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Rakesh Kurup:
I am using document.getElementById(id).focus()
Again, if the element is a <div>, you are not going be able to get this to work in a cross-browser fashion as not all browsers allow focus to <div> elements.
 
Rakesh Kurup
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It will be great if anybody can help me to resolve this kind of cross-browser issues with DIV s.
 
Herman Schelti
Ranch Hand
Posts: 387
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Rakesh,

I think Bear's advice is pretty clear:
can't you focus a specific element inside your div?

Herman
 
Rakesh Kurup
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for the help.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic