Expand textarea to fit a window

S

Steve

Hi,

I'm opening a small window with window.open. I have a textarea there,
and I want it to expand to fit the window as it's resized. How is this
possible? Thanks,

Steve
 
I

Ivo

"Steve" wrote
I'm opening a small window with window.open. I have a textarea there,
and I want it to expand to fit the window as it's resized. How is this
possible? Thanks,

If there is nothing but that textarea in the popup:
<textarea style="width:100%;height:100%"></textarea>
(perhaps combined with body{margin:0}...)

On a page with a 100% wide textarea and a small div along the top I use
this:

onresize=resized;
function resized(){
scrollTo(0,0);
var y = window.innerHeight ? window.innerHeight :
document.body.clientHeight;
// for better window height, see
// <URL: http://jibbering.com/faq/#FAQ4_9 >
var t = document.forms['f'].txt; // the textarea
t.style.height=Math.max(1,y-txt.offsetTop-1);
}

HTH
Ivo
 
T

Thomas 'PointedEars' Lahn

Ivo said:
If there is nothing but that textarea in the popup:
<textarea style="width:100%;height:100%"></textarea>
(perhaps combined with body{margin:0}...)

On a page with a 100% wide textarea and a small div along the top I use
this:

onresize=resized;
function resized(){
scrollTo(0,0);
var y = window.innerHeight ? window.innerHeight :
document.body.clientHeight;
// for better window height, see
// <URL: http://jibbering.com/faq/#FAQ4_9 >
var t = document.forms['f'].txt; // the textarea
t.style.height=Math.max(1,y-txt.offsetTop-1);
}

With proper use of CSS, that script would be not necessary either.

BTW: Your "From" header is invalid.


PointedEars
 
I

Ivo

Ivo said:
If there is nothing but that textarea in the popup:
<textarea style="width:100%;height:100%"></textarea>
(perhaps combined with body{margin:0}...)

On a page with a 100% wide textarea and a small div along the top I use
this:

onresize=resized;
function resized(){
scrollTo(0,0);
var y = window.innerHeight ? window.innerHeight :
document.body.clientHeight;
// for better window height, see
// <URL: http://jibbering.com/faq/#FAQ4_9 >
var t = document.forms['f'].txt; // the textarea
t.style.height=Math.max(1,y-txt.offsetTop-1);
}

With proper use of CSS, that script would be not necessary either.

I was kind of hoping someone would say that. How can I stretch the textarea
to the bottom without knowing the height of the div at the top?
BTW: Your "From" header is invalid.

This computer and email client are used by several individuals, and sender's
details keep being changed. Is it better now?
Ivo
 
D

Dr John Stockton

JRS: In article <[email protected]>, seen in
news:comp.lang.javascript said:
I'm opening a small window with window.open. I have a textarea there,
and I want it to expand to fit the window as it's resized. How is this
possible?

How would one do the opposite? I have a function which creates a button
which pops up a window containing a single textarea of specified size in
rows and columns, and it would be nice to have the window of correct
size to fit it. Under the circumstances, it can be assumed that the
necessary window size will fit within the screen size.

What's the best way of determining the number of lines in a function, in
any browser, given only a reference to the function?

MJDtoYMD.toString().replace(/[^\r]/g, "").length + 1 // \r\n ??
MJDtoYMD.toString().split("\r").length

If the FAQ or the Notes have anything on RegExps, a RegExp for newline
could be worth showing; I fear it may need alternatives.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,023
Latest member
websitedesig25

Latest Threads

Top