JavaScript - Netscape 6 -how do I set Focus


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: JavaScript - Netscape 6 -how do I set Focus

  1. #1
    Bob Perry Guest

    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

    . . . . . . . .
    }



  2. #2
    Dan Guest

    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
    >
    > . . . . . . . .
    > }
    >
    >




  3. #3
    bob vance Guest

    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
    >>
    >> . . . . . . . .
    >> }
    >>
    >>

    >
    >



  4. #4
    bob Perry Guest

    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
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center