473,801 Members | 2,436 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 11214
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:10 0%;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=resize d;
function resized(){
scrollTo(0,0);
var y = window.innerHei ght ? window.innerHei ght :
document.body.c lientHeight;
// 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:10 0%;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=resize d;
function resized(){
scrollTo(0,0);
var y = window.innerHei ght ? window.innerHei ght :
document.body.c lientHeight;
// 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:10 0%;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=resize d;
function resized(){
scrollTo(0,0);
var y = window.innerHei ght ? window.innerHei ght :
document.body.c lientHeight;
// 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******@clari on.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.toStri ng().replace(/[^\r]/g, "").length + 1 // \r\n ??
MJDtoYMD.toStri ng().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.demo n.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demo n.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
10220
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 horizontally, but also vertically, to fill the space. I took a look at their javascripts, but they are quite complex and convoluted since they make use of many of their own functions designed to work with their web site. Does anybody have a...
6
1855
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 with some javascript to grab the form's textarea value, and open another browser window that uses a php file that applies all the styles, etc. to the contents of what was in the text area (the guestbook entries allow simple HTML) and show the preview...
0
4996
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", now, when a user sees the FORM, begins to enter some data in the INPUT box, and he uses up all the 30 spaces for the INPUT box, and your business rule allows him to enter more than 30 characters including spaces (to be precise 50 in this case),...
2
14168
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 javascript to expand the table to the available window width. So whether the screen is maximized or partially minimized, the table fits snugly in the available display. The trouble is if I include a 'cols=' spec for the textarea box its width stays...
0
2362
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 copiedto TEXTAREA on main HTML window: wndTxtArea.value = dlgTxtArea.value; Then user may take the text for editing in HTML dialog windowonce more. The problem arises when text to be copied is multiline. Firsttime it is displayed properly after...
5
12158
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 keyboard (keypress, keyup events) * Must work on pasted input from context menu * Must work on pasted input via CTRL+V and similar * Must work on pasted input via browsers menu>Edit>Paste * Must work in Mozilla + IE and coded via W3C standards
4
7810
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 find the text and select it using the function below, BUT I can't figure out how to have the textarea automatically scroll to the selection in Firefox. Any ideas or suggestions? function search(needle,haystack,start) { var element =...
0
2876
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 window includes a button: <INPUT TYPE=SUBMIT VALUE="Test SQL" OnClick="javascript:openWin3('/cgi- bin/eisweb.exe? uni=67BD&action=TestSQL&viewname=EISWEB_TESTSQL.SQL&forceregen=true&sql='+savechanges.sql.value);return false;">
5
2933
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 author source ). Now I've added the option to make text in BOLD etc (code found on this forum), BUT it doesn't work.... This is the code (within a php file): <div align="center"> <table style="width:600px;border:solid 1px...
0
9698
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9556
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10522
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10054
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9105
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7593
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6833
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3783
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2962
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.