Javascript Q: Is there a way to determine the # of lines of text that will fit on a page?

If I’m displaying lines of text (e.g. list of records from a
database), how can I determine how many lines will fit in the browser
window?

Does javascript have the equivalent of SIGWINCH?

Thanks,

Joe

On Jun 1, 2011, at 8:31 PM, [email protected] wrote:

If I’m displaying lines of text (e.g. list of records from a
database), how can I determine how many lines will fit in the browser
window?

Does javascript have the equivalent of SIGWINCH?

Generally speaking, no. Web pages tend to grow to whatever height
their content requires, and even if you could get the current window
height from the browser, you would still need to send that information
back to the browser (maybe through an Ajax request) even then, you
still wouldn’t know about the browser’s font settings or other user
preferences that could influence how many lines of text would fit in
the current window size. Never mind what happens when the visitor
resizes her window.

What’s your goal here? Are you trying to enforce a “no scroll bars”
aesthetic or something?

Walter

Rather than displaying a fixed number of lines of text (e.g. 30), I’d
like to dynamically fill the browser window with as many
lines as it will display without scrolling.

Well, you could do this by writing each line to the browser in a
separate Ajax request, using JavaScript on the client to tell you when
no more lines will fit. This seems like a lot of work and drag on your
server for very limited benefit. Aesthetics aside, are you designing
for a device that is intentionally crippled by removing its ability to
scroll?

Walter

On Jun 1, 7:31pm, “[email protected][email protected] wrote:

If I’m displaying lines of text (e.g. list of records from a
database), how can I determine how many lines will fit in the browser
window?

Does javascript have the equivalent of SIGWINCH?

Thanks,

Joe

I fail to see what this question has to do with Rails. I know people
here have given you some ideas but you might get more from a
Javascript group than a Rails group on this question.

B.

You may do that with css. Suppose you have a div with some text content,
then give it a class as noScorll and define it as -

.noScroll{
overflow:hide;
}

Details here - http://www.w3schools.com/css/pr_pos_overflow.asp
http://www.w3schools.com/css/pr_pos_overflow.asp
On Thu, Jun 2, 2011 at 11:14 AM, [email protected] [email protected] wrote:

window?
resizes her window.
Thanks,
.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.


Ratnadeep Deshmane.