| View previous topic :: View next topic |
| Author |
Message |
cstone
Joined: 16 Apr 2005 Posts: 28
|
Posted: Mon Apr 25, 2005 10:23 pm Post subject: javascript focus |
|
|
I have a hot key that puts the focus to a certin text box by sending a javascript to the address bar. the problem is that when the focus is on a button the hot key won't work. i tried putting an if statment in the javascripe to check to see if the focus is on a button and if so change it till its not, but that didn't work either.
any help in this would be great.
this is the code that i tried to use, though it does get an error saying that there is nothing that has focus
javascript: function changeFocus(){var i=0, j=0, F=document.forms.element;if(F.type() == "button"){while(F.type() == "button"){i++;j++;F=document.forms[i].element[j];}}else{document.forms[46].element[0].focus();}}changeFocus(); _________________ cstone |
|
| Back to top |
|
 |
Payam
Joined: 07 Apr 2004 Posts: 58
|
Posted: Tue Apr 26, 2005 8:36 am Post subject: |
|
|
I get the same problem
Any help would be wonderful. Thanks |
|
| Back to top |
|
 |
bonzo Guest
|
Posted: Wed Apr 27, 2005 4:56 pm Post subject: Javascript focus |
|
|
Hi there,
Not sure what exactly you are trying to achieve, but your JavaScript is flawed.
all you need is:
| Code: |
javascript:document.forms[stringOrIndexOfTheFormYouWant].elements[stringOrIndexOfTheFormElementYouWant].focus();
|
Cheers,
Steve |
|
| Back to top |
|
 |
cstone
Joined: 16 Apr 2005 Posts: 28
|
Posted: Mon May 02, 2005 9:40 pm Post subject: |
|
|
that does work, except when a button has the focus last. the IE that i am using is probable a bit different then the one i am using because it is for a company. for some reason the.focus() works as long as a button does not have the focus. what i was trying to do, was check to see if a button has the focus and the have it continue though the elements untill something has the focus other then the button and then run the document.forms[].element[].focus() _________________ cstone |
|
| Back to top |
|
 |
cstone
Joined: 16 Apr 2005 Posts: 28
|
Posted: Mon May 09, 2005 11:02 pm Post subject: |
|
|
for some reason the button refuseds to give up the focus. but i can still set text and send commands, so a ControlSetText, edit1, <text>; followed but a ControlSend, edit1, {ENTER}; works. _________________ cstone |
|
| Back to top |
|
 |
|