AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

javascript focus

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
cstone



Joined: 16 Apr 2005
Posts: 28

PostPosted: Mon Apr 25, 2005 10:23 pm    Post subject: javascript focus Reply with quote

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
View user's profile Send private message
Payam



Joined: 07 Apr 2004
Posts: 58

PostPosted: Tue Apr 26, 2005 8:36 am    Post subject: Reply with quote

I get the same problem Smile

Any help would be wonderful. Thanks
Back to top
View user's profile Send private message Send e-mail MSN Messenger
bonzo
Guest





PostPosted: Wed Apr 27, 2005 4:56 pm    Post subject: Javascript focus Reply with quote

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

PostPosted: Mon May 02, 2005 9:40 pm    Post subject: Reply with quote

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
View user's profile Send private message
cstone



Joined: 16 Apr 2005
Posts: 28

PostPosted: Mon May 09, 2005 11:02 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group