AutoHotkey Community

It is currently May 26th, 2012, 9:23 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: javascript focus
PostPosted: April 25th, 2005, 10:23 pm 
Offline

Joined: April 16th, 2005, 1:05 am
Posts: 28
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 26th, 2005, 8:36 am 
Offline

Joined: April 7th, 2004, 2:43 pm
Posts: 62
I get the same problem :)

Any help would be wonderful. Thanks


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Javascript focus
PostPosted: April 27th, 2005, 4:56 pm 
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


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 2nd, 2005, 9:40 pm 
Offline

Joined: April 16th, 2005, 1:05 am
Posts: 28
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 9th, 2005, 11:02 pm 
Offline

Joined: April 16th, 2005, 1:05 am
Posts: 28
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


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], BrandonHotkey, fusion1920, MSN [Bot], tomoe_uehara, Yahoo [Bot] and 67 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group