Current location: Hot Scripts Forums » General Web Coding » JavaScript » Problem in focus


Problem in focus

Reply
  #1 (permalink)  
Old 07-31-07, 05:31 AM
kavithadevan kavithadevan is offline
Newbie Coder
 
Join Date: Jul 2007
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Problem in focus

Hi,
I am trying to set default focus wenever i open my registration page automatically curser focused in first text box likethis i tried but my code is not working i used On focus.Can anyone tell me how to do this


Thanks
Reply With Quote
  #2 (permalink)  
Old 07-31-07, 05:46 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
javascript Code:
  1. window.onload = function()
  2. {
  3.     document.getElementsByTagName('input')[0].focus();
  4. }
Reply With Quote
  #3 (permalink)  
Old 08-02-07, 01:29 PM
TwoD TwoD is offline
Community VIP
 
Join Date: Sep 2003
Location: 404
Posts: 1,813
Thanks: 0
Thanked 0 Times in 0 Posts
onfocus is an event handler. The code there runs when the element becomes focused, not the other way around.
__________________
[W3Schools - learn all about the standards.] [QuirksMode - Browser Quirks] [MS's Online Reference Docs] [DOM in Gecko.]
Please pay attention to stickys, announcements and forum rules, thank you.
Please also remember Code Wrappers and [SOLVED] Marking, this helps everyone.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
login, roles problem dbrook007 ASP.NET 10 11-10-06 03:42 PM
Form Display Problem neevrap02 Visual Basic 1 09-05-06 05:18 AM
focus is lost once modal form is unloaded substance Visual Basic 0 01-31-05 08:29 PM
Count problem kasic ASP.NET 1 10-20-04 12:23 AM
Asp and Microsoft Access 2002 problem gop373 ASP 2 10-06-04 09:13 AM


All times are GMT -5. The time now is 11:28 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.