[Javascript] Determining the textarea sizes

Bernu Bernard bernu at lptmc.jussieu.fr
Tue Jul 3 18:03:36 CDT 2007


Hi,
I'm trying to find out what is the necessary number of rows to  
display a complete text in a textarea of a given maxwidth

I tried the following :
	1) fix
		textarea.rows = 1
		textarea.cols = mytext.length
	2) reduce
		textarea.cols until textarea.offsetWidth < maxwidth
	3) while
		textarea.offsetHeigth < textarea.scrollHeight
		increase textarea.rows by 1

This works on FF and Safari 3, but not on Opera 9, Safari 2 because
	textarea.scrollHeight = textarea.offsetHeigth

Any Idea to check if all text is visible or not ?

Bernard



More information about the Javascript mailing list