Connecting Tech Pros Worldwide Help | Site Map

Scrolling

  #1  
Old November 16th, 2006, 07:05 AM
K.
Guest
 
Posts: n/a
Hi!

I have such code:

<textarea name="text_field">very long text</textarea>

I have filled in the value of textarea field. This value is a very long
string.
I would like to scroll this textarea field into the end.

Would you like to help me how to do that?

Thank you in advance
M. from Poland


  #2  
Old November 16th, 2006, 07:25 AM
Andrew C
Guest
 
Posts: n/a

re: Scrolling



"K." <halinacierniak@poczta.onet.plwrote in message
news:ejh3j4$nup$1@news.onet.pl...
Quote:
Hi!
>
I have such code:
>
<textarea name="text_field">very long text</textarea>
>
I have filled in the value of textarea field. This value is a very long
string.
I would like to scroll this textarea field into the end.
<script ...>
var longStringElement = getElementById("longString");
....

// Whenever you want the textarea to be scrolled to the bottom, do this:
longStringElement.scrollTop = longStringElement.scrollHeight;
</script>
....
<textarea id="longString"...... </textarea>

A.


  #3  
Old November 16th, 2006, 07:45 AM
K.
Guest
 
Posts: n/a

re: Scrolling



Użytkownik "Andrew C" <nonsense@totally.made.upnapisał w wiadomości
news:SGU6h.39505$Ib.20263@newsfe1-gui.ntli.net...
Quote:
>
"K." <halinacierniak@poczta.onet.plwrote in message
news:ejh3j4$nup$1@news.onet.pl...
Quote:
>Hi!
>>
>I have such code:
>>
><textarea name="text_field">very long text</textarea>
>>
>I have filled in the value of textarea field. This value is a very long
>string.
>I would like to scroll this textarea field into the end.
>
<script ...>
var longStringElement = getElementById("longString");
...
>
// Whenever you want the textarea to be scrolled to the bottom, do this:
longStringElement.scrollTop = longStringElement.scrollHeight;
</script>
...
<textarea id="longString"...... </textarea>
>
A.
>
>

Hi again!

Unfortunately this example doesn`t work on IE.
I have created such code:

<script language=JavaScript>

var biografiaElement = document.getElementById("biografia");
var utworyElement = document.getElementById("utwory");

alert(biografiaElement.scrollHeight);

biografiaElement.scrollTop = biografiaElement.scrollHeight;
utworyElement.scrollTop = utworyElement.scrollHeight;
</script>

Alert gives me 0 height and I don`t know why...

Please help me.
Thank you in advance
Marcin


  #4  
Old November 16th, 2006, 09:25 AM
Andrew C
Guest
 
Posts: n/a

re: Scrolling



"K." <halinacierniak@poczta.onet.plwrote in message
news:ejh64e$u6f$1@news.onet.pl...
Quote:
>
Użytkownik "Andrew C" <nonsense@totally.made.upnapisał w wiadomości
news:SGU6h.39505$Ib.20263@newsfe1-gui.ntli.net...
Quote:
>>
>"K." <halinacierniak@poczta.onet.plwrote in message
>news:ejh3j4$nup$1@news.onet.pl...
Quote:
>>Hi!
>>>
>>I have such code:
>>>
>><textarea name="text_field">very long text</textarea>
>>>
>>I have filled in the value of textarea field. This value is a very long
>>string.
>>I would like to scroll this textarea field into the end.
>>
><script ...>
>var longStringElement = getElementById("longString");
>...
>>
>// Whenever you want the textarea to be scrolled to the bottom, do this:
>longStringElement.scrollTop = longStringElement.scrollHeight;
></script>
>...
><textarea id="longString"...... </textarea>
>>
>A.
>>
>>
>
>
Hi again!
>
Unfortunately this example doesn`t work on IE.
I have created such code:
>
<script language=JavaScript>
>
var biografiaElement = document.getElementById("biografia");
var utworyElement = document.getElementById("utwory");
>
alert(biografiaElement.scrollHeight);
>
biografiaElement.scrollTop = biografiaElement.scrollHeight;
utworyElement.scrollTop = utworyElement.scrollHeight;
</script>
>
Alert gives me 0 height and I don`t know why...
>
Please help me.
Thank you in advance
Marcin
Try:

<textarea id="biografia" readonly="true" ...>
....
</textarea>

A.


  #5  
Old November 16th, 2006, 12:05 PM
K.
Guest
 
Posts: n/a

re: Scrolling



Użytkownik "Andrew C" <nonsense@totally.made.upnapisał w wiadomości
news:PlW6h.32995$TH3.14682@newsfe2-gui.ntli.net...
Quote:
>
"K." <halinacierniak@poczta.onet.plwrote in message
news:ejh64e$u6f$1@news.onet.pl...
Quote:
>>
>Użytkownik "Andrew C" <nonsense@totally.made.upnapisał w wiadomości
>news:SGU6h.39505$Ib.20263@newsfe1-gui.ntli.net...
Quote:
>>>
>>"K." <halinacierniak@poczta.onet.plwrote in message
>>news:ejh3j4$nup$1@news.onet.pl...
>>>Hi!
>>>>
>>>I have such code:
>>>>
>>><textarea name="text_field">very long text</textarea>
>>>>
>>>I have filled in the value of textarea field. This value is a very long
>>>string.
>>>I would like to scroll this textarea field into the end.
>>>
>><script ...>
>>var longStringElement = getElementById("longString");
>>...
>>>
>>// Whenever you want the textarea to be scrolled to the bottom, do this:
>>longStringElement.scrollTop = longStringElement.scrollHeight;
>></script>
>>...
>><textarea id="longString"...... </textarea>
>>>
>>A.
>>>
>>>
>>
>>
>Hi again!
>>
>Unfortunately this example doesn`t work on IE.
>I have created such code:
>>
><script language=JavaScript>
>>
> var biografiaElement = document.getElementById("biografia");
> var utworyElement = document.getElementById("utwory");
>>
>alert(biografiaElement.scrollHeight);
>>
> biografiaElement.scrollTop = biografiaElement.scrollHeight;
> utworyElement.scrollTop = utworyElement.scrollHeight;
></script>
>>
>Alert gives me 0 height and I don`t know why...
>>
>Please help me.
>Thank you in advance
>Marcin
>
Try:
>
<textarea id="biografia" readonly="true" ...>
...
</textarea>
>
A.
>
Unfortunately this example doesn`t give me a solution I would like to have.
I would like to have textarea element with updating possibilites.

I tried

var elem=document.getElementById("biografia");

if(elem)
{
elem.focus();
MoveToEnd(elem);
elem.focus();
}

but also without results.
I use IE 6.0.

Please help me, I cannot find any properly-working solution in post
archieves
Thank you Andrew for helping
Marcin


  #6  
Old November 16th, 2006, 01:45 PM
Andrew C
Guest
 
Posts: n/a

re: Scrolling



"K." <halinacierniak@poczta.onet.plwrote in message
news:ejhl49$h70$1@news.onet.pl...
Quote:
>
Użytkownik "Andrew C" <nonsense@totally.made.upnapisał w wiadomości
news:PlW6h.32995$TH3.14682@newsfe2-gui.ntli.net...
Quote:
>>
>"K." <halinacierniak@poczta.onet.plwrote in message
>news:ejh64e$u6f$1@news.onet.pl...
Quote:
>>>
>>Użytkownik "Andrew C" <nonsense@totally.made.upnapisał w wiadomości
>>news:SGU6h.39505$Ib.20263@newsfe1-gui.ntli.net...
>>>>
>>>"K." <halinacierniak@poczta.onet.plwrote in message
>>>news:ejh3j4$nup$1@news.onet.pl...
>>>>Hi!
>>>>>
>>>>I have such code:
>>>>>
>>>><textarea name="text_field">very long text</textarea>
>>>>>
>>>>I have filled in the value of textarea field. This value is a very
>>>>long string.
>>>>I would like to scroll this textarea field into the end.
>>>>
>>><script ...>
>>>var longStringElement = getElementById("longString");
>>>...
>>>>
>>>// Whenever you want the textarea to be scrolled to the bottom, do
>>>this:
>>>longStringElement.scrollTop = longStringElement.scrollHeight;
>>></script>
>>>...
>>><textarea id="longString"...... </textarea>
>>>>
>>>A.
>>>>
>>>>
>>>
>>>
>>Hi again!
>>>
>>Unfortunately this example doesn`t work on IE.
>>I have created such code:
>>>
>><script language=JavaScript>
>>>
>> var biografiaElement = document.getElementById("biografia");
>> var utworyElement = document.getElementById("utwory");
>>>
>>alert(biografiaElement.scrollHeight);
>>>
>> biografiaElement.scrollTop = biografiaElement.scrollHeight;
>> utworyElement.scrollTop = utworyElement.scrollHeight;
>></script>
>>>
>>Alert gives me 0 height and I don`t know why...
>>>
>>Please help me.
>>Thank you in advance
>>Marcin
>>
>Try:
>>
><textarea id="biografia" readonly="true" ...>
>...
></textarea>
>>
>A.
>>
>
Unfortunately this example doesn`t give me a solution I would like to
have.
I would like to have textarea element with updating possibilites.
>
I tried
>
var elem=document.getElementById("biografia");
>
if(elem)
{
elem.focus();
MoveToEnd(elem);
elem.focus();
}
>
but also without results.
I use IE 6.0.
>
Please help me, I cannot find any properly-working solution in post
archieves
Thank you Andrew for helping
Marcin
If you need to add content to the textarea programmatically, readonly won't
stop you, but it does seem to allow the '...scrollTop = ...scrollHeight'
trick to work in IE -- at least it did in IE7 for me.

Only if you need for the user to add content via the keyboard will readonly
cause you difficulties. Even then, one work-around may be to switch readonly
off and on at different times (e.g. set readonly to true briefly when you
add content programmatically and need to auto-scroll to the bottom).

Does this help?

A.


Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Event after scrolling Chamnap answers 3 June 14th, 2007 08:35 AM
Scrolling text PythonistL answers 5 November 16th, 2006 08:05 AM
need help looking for a cross-browsers vertical scrolling script P2P answers 2 March 15th, 2006 02:45 PM
Simple Scrolling Text Box Midas NDT Sales answers 1 July 20th, 2005 12:20 PM