Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with Page shifting over when element recieves focus

Status
Not open for further replies.

Unsubscribed

Programmer
Jun 8, 1999
11
CA
Hi,
I have some javascript error checking that checks if a user has entered something into a required field. If they haven't, it sets the focus to that text box. The strange thing is that in Netscape 4.76 when focus is returned to the text field, the page lines itself up so that the textbox is at the far left side of the browser screen, resulting in the user having to scroll to see the label of the textbox. Does anyone have an idea of how I might stop this? Works fine as is in IE, just not in Netscape 4.76...

Thanks
 
Thanks, for the suggestion :)
QA wants the cursor to show up in the text field that is wrong, so I can't put the focus on the label unfortunately. Is there any other way I can force the content to align correctly?
thanks.
 
test_field_id.select();
label_id.focus();

so you'll still focus on the label (correct position) and the text field content will be highlighted

now if you really want to "force the content to alogn correctly" use css but it'll be a headache for nothing (almost)
 
I fear Friday has taken it's toll on me... I cannot make this work. I get an error message saying that the label is not an object. Am I referencing it wrong?
Code example is below, thanks very much for you help :)

<b><LABEL ID=&quot;firstnamelabel&quot; FOR=&quot;firstname&quot;>First Name:</LABEL></b>

<INPUT TYPE=&quot;Text&quot; NAME=&quot;firstname&quot; VALUE=&quot;&quot; MAXLENGTH=&quot;40&quot; TABINDEX=&quot;1&quot; onFocus=&quot;nextfield ='lastname';&quot;>

if (document.applicationForm.firstname.value == &quot;&quot;)
{
alert(&quot;Please enter your first name.&quot;);

//test_field_id.select();
//label_id.focus();
document.applicationForm.firstname.select();
document.applicationForm.firstnamelabel.focus();

return false;
}

 
yes i think &quot;label&quot; is a browser specific tag
try a named div - this is cross browser for sure and you can use it the way you want to
 
Thanks :)

Using the div works in IE, but I am still getting the same error in Netscape 4.7. I named the div &quot;firstnamelabel&quot; and am still getting that it is 'undefined'.... any idea what I am doing wrong please?

<DIV ID=&quot;firstnamelabel&quot; >

referred to in javascript as follows:
firstnamelabel.focus();

 
-> if i remember correctly, netscape needs div to be absolutly positionned to &quot;view&quot; them
 
Tried adding absolute positioning, and am getting the same error, that firstnamelabel is 'undefined'...
 
I tried all the options I could locate before ever posting this thread :) Thanks for your assistance :)
 
did you make it work with netscape doc or are you still stuck ??
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top