473,394 Members | 2,100 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Fastest finger first

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.

Apr 22 '06 #1
8 1939
[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)
Apr 22 '06 #2
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.

Apr 22 '06 #3
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)
Apr 22 '06 #4
On 2006-04-22 11:23:55 +0200, "Evertjan." <ex**************@interxnl.net> 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

Apr 22 '06 #5
Touffy wrote on 22 apr 2006 in comp.lang.javascript:
On 2006-04-22 11:23:55 +0200, "Evertjan."
<ex**************@interxnl.net> 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)
Apr 22 '06 #6

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 '06 #7
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 '06 #8
On 2006-04-22 19:06:12 +0200, "Evertjan." <ex**************@interxnl.net> said:
Touffy wrote on 22 apr 2006 in comp.lang.javascript:
On 2006-04-22 11:23:55 +0200, "Evertjan."
<ex**************@interxnl.net> 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

Apr 26 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Simon | last post by:
Hi, If I have a string, (variable len), and I am looking for the first position of one char in array starting from position 'x' For example, // the 'haystack' $string = "PHP is great,...
9
by: Rune Strand | last post by:
Hi, If I have a lot of integers and want do something with each digit as integer, what is the fastest way to get there? Eg. Make 12345 into an iterable object, like or "12345" (Btw: What is...
4
by: laurenq uantrell | last post by:
I am trying to determine which of three stored procedure designs are fastest in the Query Analyzer: One query is a straight SELECT query with all desired rows and a dozen (tblName.RowName =...
11
by: hoopsho | last post by:
Hi Everyone, I am trying to write a program that does a few things very fast and with efficient use of memory... a) I need to parse a space-delimited file that is really large, upwards fo a...
1
by: Jim Hubbard | last post by:
I want to do driver development and activeX creation......what would you suggest as far as the best/fastest path to learning C++ for these tasks?
3
by: Harry Haller | last post by:
What is the fastest way to search a client-side database? I have about 60-65 kb of data downloaded to the client which is present in 3 dynamically created list boxes. The boxes are filled from 3...
1
by: Harry Haller | last post by:
What is the fastest way to search a client-side database? I have about 60-65 kb of data downloaded to the client which is present in 3 dynamically created list boxes. The boxes are filled from 3...
1
by: Esmael | last post by:
Hi... I'ved develop a Daily Time Record System in my previous projects using bascode as input...and this was a years ago... Recently.. my projects requires a finger scanner as input is there...
4
by: victor robbin | last post by:
Hi... is it possible to move a picture around the form with human fingers? I have a form with one picture on it........when my finger touch one picture, I would like the picture to follow it...
9
by: chandru4ni | last post by:
Hello, I know there exits Windows APIs for reading the logon credentials. We can read the logon password using the APIs. I am working on a module which requires the finger print ID associated...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.