Page 1 of 1

Making sure active text is showing

Posted: Thu Oct 13, 2005 9:25 am
by Bill H
I'm adapting a third-party spellchecker for which the core programming is excellent and the interface is awful. Getting it nicely into shape, but have come upon this following stumbling point.

Code: Select all

<div class='black p13' style='width:390px; height:235px; background:#f2f2f2; padding:10px; margin-left:10px; border:1px solid #000000; float:left; overflow:auto'>
text goes here
</div>
The text being checked is in the <div> with the erroneous word highlighted. If the text does not fit there are scrollbars, which works just fine, but if the highlighted word is near the end of the text it is not shown and you have to scroll down to get it into the displayed area.

Generically, is there a way to be sure that a given portion of the text is displayed within that <div>?

Posted: Thu Oct 13, 2005 7:20 pm
by feyd
using scrollIntoView with the DOM object of the div may work..

Posted: Thu Oct 13, 2005 11:57 pm
by Bill H
That's a bit advanced for me. Can you point me toward some, hmmm, tutorials or something?

Posted: Fri Oct 14, 2005 12:02 am
by feyd
search the board for it with my name as author (should result in five threads)

Posted: Fri Oct 14, 2005 8:47 am
by Bill H
Thanks, the posts were illuminating. The scrollIntoView() seems always to be called with a parameter of false, and I couldn't follow how it called any particular piece of text into view. In fact, I saw how the <div> (<textarea>, whatever) is referenced, but not the content at all.

This is becoming academic, because it seems that the text cannot be written back to the HTML element if it contains any newlines and so the newlines are being stripped out. This is an unacceptable condition, so if I cannot find a way to write it back without stripping the newlines the product is getting dumped.

But it's interesting, so...