aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes document.forms[0].elements.focus() is not working in IE 7.0+ and FF 3.0 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "document.forms[0].elements.focus() is not working in IE 7.0+ and FF 3.0" Watch "document.forms[0].elements.focus() is not working in IE 7.0+ and FF 3.0" New topic
Author

document.forms[0].elements.focus() is not working in IE 7.0+ and FF 3.0

Fidel Edwards
Ranch Hand

Joined: Mar 19, 2008
Posts: 231
Hello Friends,

I am trying the following code since long time .As It prompts and runs fine in IE 6.0 but in all the upper versions it fails .As cursor moves to next textbox rather than the same .




I am using that code in my JSP as





Please help me I tried lots of things but failed !!!


God Gave Me Nothing I Wanted, He Gave Me Everything I Needed.
OCPJP6
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Do the id.focus() after the alert statement

You also probably want to use onblur

Eric
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Apart from this problem, using document.forms[x] instead of document.formname or document.getElementById(formid) is a bad practice and receipt for trouble.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61206
    
  66

Indeed. Using names instead of ids for DOM navigation is a quaint and old-fashioned practice that should be avoided.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Fidel Edwards
Ranch Hand

Joined: Mar 19, 2008
Posts: 231
Bauke Scholtz wrote:Apart from this problem, using document.forms[x] instead of document.formname or document.getElementById(formid) is a bad practice and receipt for trouble.


Thanks For Early Reply! But I tried lots of things but failed .As all the time cursor moves to next textbox.It is working fine with IE6.0 but for latest browser it prompts but on clicking OK button it moves to next textbox without further prompting.
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Someone said something about onblur.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
onchange is not fired on every keystroke. It is fired when focus is removed from the element and the data has changed.

Eric
Fidel Edwards
Ranch Hand

Joined: Mar 19, 2008
Posts: 231
Eric Pascarello wrote:onchange is not fired on every keystroke. It is fired when focus is removed from the element and the data has changed.

Eric


Thanks Eric !! But It is Still not running .
I am sending my javascript code which is in js file



I am calling this function as



It is not working in IE 7.0 and FF 3.0 !!




Fidel Edwards
Ranch Hand

Joined: Mar 19, 2008
Posts: 231
Any One can solve this problem ??
 
jQuery in Action, 2nd edition
 
subject: document.forms[0].elements.focus() is not working in IE 7.0+ and FF 3.0