focus() onLoad

This is a discussion on "focus() onLoad" within the JavaScript Forum section. This forum, and the thread "focus() onLoad are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Apr 22nd, 2006, 05:13
Junior Member
Join Date: Aug 2005
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
focus() onLoad

Can someone resolve my issue with using the focus() attribute of an input in an onLoad handler? (not directly in the handler, but in a function called from the handler) It doesn't seem to work, but I may be wrong. Here's the basic code, minus a whole bunch of php. I'd link you to the website if it existed. I'm running this off my computer for testing.

HTML: Select all
<html>
<body>
<form name="mainform" method="post">
 
<script language="javascript">
<!--
function give_focus_answer()
{
document.mainform.answer.focus();
}
-->
</script>
 
<table align="center" valign="middle" width="300">
<tr><td>Score: : % </td></tr>
<tr><td><input type="text" readonly width="100" name="word" value="" /></td></tr>
<tr><td><input type="text" name="answer" width="100" onLoad="give_focus_answer();" /></td></tr>
<tr><td><input type="submit" name="submit" width="30" value="Submit" />
<input type="submit" name="start" width="30" value="Start" /></td></tr>
</table>
 
</form>
</body>
</html>
Reply With Quote

  #2 (permalink)  
Old Apr 22nd, 2006, 17:34
Junior Member
Join Date: Aug 2005
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Re: focus() onLoad

Nevermind. I figured out I needed to move the handler up to the body tag. It works fine now.
Reply With Quote
Reply

Tags
focus, onload

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Is it possible to set the FOCUS() dynamically with javascript AJAY KUMAR JavaScript Forum 2 Jul 9th, 2007 03:29
Cursor focus getting lost in IE kallol Web Page Design 5 Apr 10th, 2007 08:09
how to give focus for text fields danieldear Flash & Multimedia Forum 4 Aug 26th, 2006 05:42
text box focus Prakashcee Flash & Multimedia Forum 2 Dec 6th, 2005 08:35


All times are GMT. The time now is 19:21.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43