resizable text areas

by anders pearson Fri 01 Apr 2005 11:28:57

i did this about a year ago but forgot to really mention it to anyone. now, there seems to be a renewed interest in all things javascript/dhtml, so maybe someone will find it useful. it's basically just a little javascript hack that makes it so users can dynamically resize a textarea on a page. it works in every modern browser i've tried it in and degrades gracefully to a plain old textarea in any browser that doesn't support it or has javascript disabled.

i'm trying to make a point of sharing more of these little tricks with the world.

the script uses a drag and drop implementation from elsewhere. i'm not crazy about it, but i wasn't about to write my own. at some point though, i'd like to remove the little bit of javascript in the page that it requires to make it more in line with the idea of unobtrusive javascript. that will probably require modifying the drag + drop library though, or implementing the parts of it that i need on my own.

i'm also really interested in taking this technique and turning it into a greasemonkey script so i can resize the textareas on any page on the web.

TAGS: programming dhtml javascript


As far as that last bit goes, check this out:

very cool. i may tweak it a bit to make it reflow the page when the textareas are resized. as is, just the textarea is expanded and other inputs on the page can end up overlapping it so it doesn't really work on some pages.

Very nice, but it's got one fairly dangerous bug: If the textarea is resized to zero height, only the single top pixel row of the button can be used to resize the textarea. The equivalent goes for the width.

doesn't work in IE 6

This seems like a nice thing to have as a Greasemonkey script, but it's probably not stable or obvious enough to use in public.

It's true, it doesn't work in IE. I fiddled a bit with your example and found out that for some reason (I didn't analyse walter zorn's script) you have to put the script include tag inside the body tag to make it work in IE. I guess making it unobtrusive will be a bit of work.

formatting is with Markdown syntax. Comments are not displayed until they are approved by a moderator. Moderators will not approve unless the comment contributes value to the discussion.

remember info?