Making sure active text is showing

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Bill H
DevNet Resident
Posts: 1136
Joined: Sat Jun 01, 2002 10:16 am
Location: San Diego CA
Contact:

Making sure active text is showing

Post 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>?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

using scrollIntoView with the DOM object of the div may work..
User avatar
Bill H
DevNet Resident
Posts: 1136
Joined: Sat Jun 01, 2002 10:16 am
Location: San Diego CA
Contact:

Post by Bill H »

That's a bit advanced for me. Can you point me toward some, hmmm, tutorials or something?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

search the board for it with my name as author (should result in five threads)
User avatar
Bill H
DevNet Resident
Posts: 1136
Joined: Sat Jun 01, 2002 10:16 am
Location: San Diego CA
Contact:

Post 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...
Post Reply