Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4345776
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T12:04:58+00:00 2026-05-21T12:04:58+00:00

I have a div with many textual lines in it. The div is height

  • 0

I have a div with many textual lines in it. The div is height restricted and hence I have a scroll. Is there a way in java script to scroll to a specified line.

Had it been in html page I can always do it with bookmarks , how to do it for rich text boxes or any html container with the help of java script.

Any help much appreciated.

Nandish

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T12:04:59+00:00Added an answer on May 21, 2026 at 12:04 pm

    The problem you have here is the concept “line”. Since you have a box drawn in the browser, with a given width (maybe dynamic), and a text inside it, the lines depends on the wrapping.

    For example, the text: “hello world, I need my pizza now” would be two lines if the width is really small, or a single line, if the width is enough to fit this text.

    What I mean with this, is that “line” is a concept relative to the wrapping itself, so even counting lines inside a div its not possible.

    It is different if your lines are defined by the user, with line feeds and carriage returns, or with
    or whatever, but if the lines are generated by the wrapping, this happens at rendering time, and you have no idea of how it would happen.

    If you have a fixed font size, you can speculate the number of lines, by a simple division of the height of the box / font size + space between lines.

    However, if you text is rich, it can contain images, etc, and this won’t work.

    Another possible solution is to use getClientRects (this worked for me)

    https://developer.mozilla.org/en/DOM/element.getClientRects

    that returns a collection of text rectangles objects:

    http://help.dottoro.com/ljgupwlp.php

    Hope this helps a bit, I faced this problem twice before, and its not as easy a function call, you should understand what means lines, wrapping, clienrects, textrectangles, fonts…

    Good luck!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an overflow:auto div with specific max-height. That div contains many items as
I have a fixed width DIV containing a table with many columns, and need
I have many DIV with the same class name, let save wmplayer. I want
I have many div in my aspx page. how to update the content of
I have a div with many many html elements like other divs, trs, tds,
I have a DIV with many elements that are all clickable. Each one with
I have a div class named subproperties. In that div, I have many div
I have a div that contains many floated child items. Each child item is
I have a div that contains many spans and each of those spans contains
I have a div that contains many spans and each of those span s

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.