View Full Version : focus on text field w/o body using AJAX

08-08-2007, 03:42 PM
****focus on text field when page loads using AJAX****

Hello all,

In our application we are using AJAX for our home page and all the related pages are included to it.

Its working fine. But i am unable to do focus on the first text field in the included pages as we do for normal form using onLoad & document.formname.elementname.focus funtion in body tag.

Here thre problem is- since it is included pages, we dont have body or form to set focus using above mentioned js function.

Is there any solution for this?
Could any one please tell me the solution for this problem as it is very important.

Thanks in advance,

08-09-2007, 09:25 AM
Please post a link to the page on your site that contains the problematic script so we can check it out.

08-09-2007, 03:41 PM
This requires a small transparent .gif image, or really any small image, as it will never be seen. Example code for a page with a form to be loaded via Ajax w/ it's first text field brought to focus:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<form action="#" name="test">
<input type="text" name="text1"><br>
<input type="text" name="text2"><br>
<input type="submit" value="Go">
<img style="visibility:hidden;position:absolute;top:-1000px;" src="spacer.gif"