473,507 Members | 2,388 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Expand textarea to fit a window

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

Jul 23 '05 #1
4 11193
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
Jul 23 '05 #2
Ivo wrote:
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
Jul 23 '05 #3
Ivo

"Thomas 'PointedEars' Lahn" wrote
Ivo wrote:
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
PointedEars

Jul 23 '05 #4
JRS: In article <40******@clarion.carno.net.au>, seen in
news:comp.lang.javascript, Steve <nospam@nopes.?> posted at Thu, 27 May
2004 10:15:53 :

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.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
10182
by: David | last post by:
It's sad to say, but when using the AOL web site, like to send an email, they have a nifty capability such that when a window is resized, the textarea where the message is input expands not only...
6
1821
by: dan glenn | last post by:
hi. I'm having a problem using javasript to pass the value of a textarea (in a form) to a PHP script file. I want to code a 'preview' function into a guestbook entry page, using an HTML link...
0
4978
by: Doug Baroter | last post by:
Hi, Here's the problem I want to solve. Suppose you design an HTML FORM with three elements of INPUT, TEXTAREA AND SUBMIT, you specify the length for the INPUT box as Size="30" and MaxLen="50",...
2
14131
by: John Ramsden | last post by:
I have a form containing a table whose cells include prompt text strings and input areas, one of which is a textarea. These are specified using only percent values, and I use some simple...
0
2315
by: Krzysztof Fink-Finowicki via .NET 247 | last post by:
I have problem with TEXTAREA HTML tags in my Web application (MSIE 6.0). User fills-in content of TEXTAREA on HTML dialog window. After accepting, content of TEXTAREA from dialog window is...
5
12119
by: Jesper Rønn-Jensen | last post by:
I have a textarea that must be limited to 70 characters. No big deal -- at least so I thought. * Textarea must not exceed 70 characters * Exceeding content must be cut off * Must work on input by...
4
7739
by: Keith Bentrup | last post by:
Hi all, I wrote a simple search function to find text in a textarea where not all the text is visible (ie. the text box displays 10 lines but there may be more than 1000 lines to search). I can...
0
2852
by: korggrok | last post by:
I have a dialog window that pops up from the main app browser window. The window contains a form (name="savechanges") that includes an input (name="sql") that is a textarea input. The dialog...
5
2914
by: sunadumari | last post by:
Hi folks, hope I'm in the wright section (I'm a newbie). I've got a textarea that, with the click on a button, shows the html-look of the data in the textarea. This script I found on the net (with...
0
7223
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7111
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7376
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7031
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7485
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5042
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
1542
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
760
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
412
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.