-
JavaScript - Netscape 6 -how do I set Focus
In a validation routine, I want to return focus to the form field of any invalid
field.
The code below works for IE and Netscape 4, but I cannot find code that works
for Netscape 6.
I tried variations of
document.getElementById["formname"].elements["formfield"].focus();
but I’m just not getting it.
Can somebody help me out?
Thanks.
//------------------------------------------------------------
function validateDate(docForm, editField, param, param, displayMsg) {
var fieldValue = editField.value;
if ( invalidDate ) {
if ( browserVersion == 'IE' ) {
editField.focus();
editField.select();
} else {
if ( browserVersion == 'NS6') {
editField.focus(); //this won't work
. . . . . . . .
}
-
Re: JavaScript - Netscape 6 -how do I set Focus
The document.getElementById() method is DOM1 and thus I don't think it'd
work with NS 4.x, maybe you mean it works for IE5 and up and NS 6.x, as for
NS4.x, document.FORMNAME.ELEMENTNAME.focus() works for all IE and NS
versions, at least 2.x and up afaik.
Dan
"Bob Perry" <bob_perry@aoncons.com> wrote in message
news:3c36090c$1@147.208.176.211...
>
> In a validation routine, I want to return focus to the form field of any
invalid
> field.
> The code below works for IE and Netscape 4, but I cannot find code that
works
> for Netscape 6.
> I tried variations of
>
document.getElementById["formname"].elements["formfield"].focus();
> but I'm just not getting it.
> Can somebody help me out?
> Thanks.
>
>
> //------------------------------------------------------------
> function validateDate(docForm, editField, param, param, displayMsg) {
>
> var fieldValue = editField.value;
>
> if ( invalidDate ) {
> if ( browserVersion == 'IE' ) {
> editField.focus();
> editField.select();
>
> } else {
> if ( browserVersion == 'NS6') {
> editField.focus(); //this won't work
>
> . . . . . . . .
> }
>
>
-
Re: JavaScript - Netscape 6 -how do I set Focus
The "code" that should have worked was at the end of his post.
> editField.focus(); //this won't work
The above line works for NS4 and IE (according to him) but not NS6.
...
> } else {
> if ( browserVersion == 'NS6') {
> editField.focus(); //this won't work
He tried document.getElementById() for NS6 *because*
editField.focus();
didn't work.
"Dan" <dann@hotpop.com> wrote:
> The document.getElementById() method is DOM1 and thus I don't think
it'd
>work with NS 4.x, maybe you mean it works for IE5 and up and NS 6.x, as
for
>NS4.x, document.FORMNAME.ELEMENTNAME.focus() works for all IE and NS
>versions, at least 2.x and up afaik.
>
> Dan
>"Bob Perry" <bob_perry@aoncons.com> wrote in message
>news:3c36090c$1@147.208.176.211...
>>
>> In a validation routine, I want to return focus to the form field of any
>invalid
>> field.
>> The code below works for IE and Netscape 4, but I cannot find code that
>works
>> for Netscape 6.
>> I tried variations of
>>
>document.getElementById["formname"].elements["formfield"].focus();
>> but I'm just not getting it.
>> Can somebody help me out?
>> Thanks.
>>
>>
>> //------------------------------------------------------------
>> function validateDate(docForm, editField, param, param, displayMsg) {
>>
>> var fieldValue = editField.value;
>>
>> if ( invalidDate ) {
>> if ( browserVersion == 'IE' ) {
>> editField.focus();
>> editField.select();
>>
>> } else {
>> if ( browserVersion == 'NS6') {
>> editField.focus(); //this won't work
>>
>> . . . . . . . .
>> }
>>
>>
>
>
-
Re: JavaScript - Netscape 6 -how do I set Focus
Guys, thanks for your help. I found out the real problem was with Netscape
6. i can set focus in Netscape 6 with an onLoad command, or if there is only
1 form field, but if there is more than 1 form field then setting focus does
not work. Its easy to put together a test page with 3 forms and prove it
for yourself. We've notified Netscape and received an automated response,
and don't expect to hear any more from them.
If anyone can come up with a workaround that will set focus I'd love to hear
about it.
-Bob
"bob vance" <bobvance@alumni.caltech.edu> wrote:
>
>The "code" that should have worked was at the end of his post.
>
>> editField.focus(); //this won't work
>
>The above line works for NS4 and IE (according to him) but not NS6.
> ...
>> } else {
>> if ( browserVersion == 'NS6') {
>> editField.focus(); //this won't work
>
>He tried document.getElementById() for NS6 *because*
> editField.focus();
>didn't work.
>
>"Dan" <dann@hotpop.com> wrote:
>> The document.getElementById() method is DOM1 and thus I don't think
>it'd
>>work with NS 4.x, maybe you mean it works for IE5 and up and NS 6.x, as
>for
>>NS4.x, document.FORMNAME.ELEMENTNAME.focus() works for all IE and NS
>>versions, at least 2.x and up afaik.
>>
>> Dan
>>"Bob Perry" <bob_perry@aoncons.com> wrote in message
>>news:3c36090c$1@147.208.176.211...
>>>
>>> In a validation routine, I want to return focus to the form field of
any
>>invalid
>>> field.
>>> The code below works for IE and Netscape 4, but I cannot find code that
>>works
>>> for Netscape 6.
>>> I tried variations of
>>>
>>document.getElementById["formname"].elements["formfield"].focus();
>>> but I'm just not getting it.
>>> Can somebody help me out?
>>> Thanks.
>>>
>>>
>>> //------------------------------------------------------------
>>> function validateDate(docForm, editField, param, param, displayMsg) {
>>>
>>> var fieldValue = editField.value;
>>>
>>> if ( invalidDate ) {
>>> if ( browserVersion == 'IE' ) {
>>> editField.focus();
>>> editField.select();
>>>
>>> } else {
>>> if ( browserVersion == 'NS6') {
>>> editField.focus(); //this won't work
>>>
>>> . . . . . . . .
>>> }
>>>
>>>
>>
>>
>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks