Fastest finger first

Discussion in 'Javascript' started by Phil_Harvey, Apr 22, 2006.

  1. Phil_Harvey

    Phil_Harvey Guest

    I need to know how I scroll to a particular element with javascript.

    <label>&gt; <input name="tf_command" size="50" type="text"></label>

    for example I want the screen to scroll to this input box whenever
    something is entered.
    I have delbt with all the other stuff I want it to do, I just need to
    know how to make it scroll.

    Cheers
    Phil.
     
    Phil_Harvey, Apr 22, 2006
    #1
    1. Advertising

  2. Phil_Harvey

    Evertjan. Guest

    Re: scrolling to, was: Fastest finger first

    [Please give a relevant description to your Q]

    Phil_Harvey wrote on 22 apr 2006 in comp.lang.javascript:
    > I need to know how I scroll to a particular element with javascript.


    IE and possebly others have:

    object.scrollIntoView( [bAlignToTop] )

    > <label>&gt; <input name="tf_command" size="50" type="text"></label>
    >
    > for example I want the screen to scroll to this input box whenever
    > something is entered.


    Why not use:

    <a name='here'></a>
    &gt; <input name="tf_command" size="50" type="text">

    script:

    location.href='#here'

    > I have delbt with all the other stuff I want it to do, I just need to
    > know how to make it scroll.


    A man of limited desires?

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Apr 22, 2006
    #2
    1. Advertising

  3. Phil_Harvey

    Phil_Harvey Guest

    Re: scrolling to, was: Fastest finger first

    The older I get, the more that I code, the more I realise that things
    should be small and simple. Desires, wishes, methods, questions,
    answers. Ask small and ask many.

    I think the location.href is a good option. I do have to make sue it
    fits with the other bits and squiggles in my code.

    Is window.scrollto supported in all browsers?

    Thank you very much.
     
    Phil_Harvey, Apr 22, 2006
    #3
  4. Phil_Harvey

    Evertjan. Guest

    Re: scrolling to, was: Fastest finger first

    Phil_Harvey wrote on 22 apr 2006 in comp.lang.javascript:

    > The older I get, the more that I code, the more I realise that things
    > should be small and simple. Desires, wishes, methods, questions,
    > answers. Ask small and ask many.
    >
    > I think the location.href is a good option. I do have to make sue it
    > fits with the other bits and squiggles in my code.
    >
    > Is window.scrollto supported in all browsers?


    I only test IE & FF, and would like to test Safari.

    scrollto() I never tested yet.

    Strange, btw, scrollTo and scrollBy
    are only defined for the window object,
    should also be nice for scrollable divs.


    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Apr 22, 2006
    #4
  5. Phil_Harvey

    Touffy Guest

    Re: scrolling to, was: Fastest finger first

    On 2006-04-22 11:23:55 +0200, "Evertjan." <> said:

    >> <label>&gt; <input name="tf_command" size="50" type="text"></label>
    >>
    >> for example I want the screen to scroll to this input box whenever
    >> something is entered.

    >
    > Why not use:
    >
    > <a name='here'></a>
    > &gt; <input name="tf_command" size="50" type="text">
    >
    > script:
    >
    > location.href='#here'


    a similar but slightly shorter (and simpler) way to define fragment
    identifiers is to use the id attribute of any element (should work with
    all browsers that support HTML 4).

    so, no <a>, just change the <input> to this :

    <input id="here" name="tf_command" size="50" type="text">

    and use the same script to scroll.


    --
    David Junger
     
    Touffy, Apr 22, 2006
    #5
  6. Phil_Harvey

    Evertjan. Guest

    Re: scrolling to, was: Fastest finger first

    Touffy wrote on 22 apr 2006 in comp.lang.javascript:

    > On 2006-04-22 11:23:55 +0200, "Evertjan."
    > <> said:
    >
    >>> <label>&gt; <input name="tf_command" size="50" type="text"></label>
    >>>
    >>> for example I want the screen to scroll to this input box whenever
    >>> something is entered.

    >>
    >> Why not use:
    >>
    >> <a name='here'></a>
    >> &gt; <input name="tf_command" size="50" type="text">
    >>
    >> script:
    >>
    >> location.href='#here'

    >
    > a similar but slightly shorter (and simpler) way to define fragment
    > identifiers is to use the id attribute of any element (should work
    > with all browsers that support HTML 4).
    >
    > so, no <a>, just change the <input> to this :
    >
    > <input id="here" name="tf_command" size="50" type="text">
    >
    > and use the same script to scroll.


    This script?:

    location.href='#here'

    I don't think so!

    What srpt are you referring to?

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Apr 22, 2006
    #6
  7. Phil_Harvey

    Guest

    Phil_Harvey wrote:
    > I need to know how I scroll to a particular element with javascript.
    >
    > <label>&gt; <input name="tf_command" size="50" type="text"></label>
    >
    > for example I want the screen to scroll to this input box whenever
    > something is entered.
    > I have delbt with all the other stuff I want it to do, I just need to
    > know how to make it scroll.
    >
    > Cheers
    > Phil.


    Just a quick thought, you could use internal links in order to scroll
    to the anchor. Although this wouldn't exactly "scroll", it would bring
    you there. If you have any information that needs to stay in place in
    a dynamic form element, please disregard this comment, as internal
    links reload the page into a certain configuration, removing all
    dynamic form info.
     
    , Apr 23, 2006
    #7
  8. Phil_Harvey

    Guest

    With this internal linking structure, you could just use the onChange
    event in order to have the site execute a script every time the client
    changes the input box. Using that, you could add a simple
    modification:
    <input type=text name="..." onChange()="internal_link_scroll();">
    ...
    <script type="text/javascript">
    function internal_link_scroll
    {
    location.href = "whatever your internal link's name is, preceded by
    a pound sign (#)"; //Your internal link might be something like:
    #scrolleditem
    }
    </script>
    ...

    I remain your most humble and Ob't Sv't in our battle against the King.

    --
    Patrick Reilly
    1st Coy.
    Colonel Seth Warner's Regiment
     
    , Apr 23, 2006
    #8
  9. Phil_Harvey

    Touffy Guest

    Re: scrolling to, was: Fastest finger first

    On 2006-04-22 19:06:12 +0200, "Evertjan." <> said:

    > Touffy wrote on 22 apr 2006 in comp.lang.javascript:
    >
    >> On 2006-04-22 11:23:55 +0200, "Evertjan."
    >> <> said:
    >>>> <label>&gt; <input name="tf_command" size="50" type="text"></label>
    >>>>
    >>>> for example I want the screen to scroll to this input box whenever
    >>>> something is entered.
    >>>
    >>> Why not use:
    >>>
    >>> <a name='here'></a>
    >>> &gt; <input name="tf_command" size="50" type="text">
    >>>
    >>> script:
    >>>
    >>> location.href='#here'

    >>
    >> a similar but slightly shorter (and simpler) way to define fragment
    >> identifiers is to use the id attribute of any element (should work
    >> with all browsers that support HTML 4).
    >>
    >> so, no <a>, just change the <input> to this :
    >>
    >> <input id="here" name="tf_command" size="50" type="text">
    >>
    >> and use the same script to scroll.

    >
    > This script?:
    >
    > location.href='#here'
    >
    > I don't think so!
    >
    > What srpt are you referring to?


    yes, this very script. The id attribute in any displayed element is
    treated just like the name attribute in <a> tags, as far as fragment
    identifiers are connerned, including the way you refer to them in a URL.

    http://www.w3.org/TR/html4/struct/global.html#adef-id


    --
    David Junger
     
    Touffy, Apr 26, 2006
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. matt
    Replies:
    9
    Views:
    467
    Andrew Thompson
    Oct 27, 2004
  2. Diana
    Replies:
    0
    Views:
    447
    Diana
    Dec 1, 2004
  3. Guest
    Replies:
    7
    Views:
    701
    Walter Wang [MSFT]
    Jun 28, 2006
  4. rohinikambde

    FINGER PRINT SCANNER

    rohinikambde, Jun 4, 2012, in forum: Ruby
    Replies:
    0
    Views:
    617
    rohinikambde
    Jun 4, 2012
  5. Jeff Higgins

    Re: finger print

    Jeff Higgins, Feb 3, 2014, in forum: Java
    Replies:
    5
    Views:
    154
    Jeff Higgins
    Feb 5, 2014
Loading...

Share This Page