[Javascript] js for inserting a \n every 80 chars?

Triche Osborne wdlists at triche-osborne.com
Fri Dec 29 12:02:09 CST 2006


LIFO:
Matt Murphy wrote:
>  
> Is there somewhere I can go to look up javascript functions?

http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Guide

> Is there a javascript version of str_replace()?
>
string.replace( regexp, replacement )

> I have a script that takes user input from a textarea and dumps it into
> a <pre> element in a new table cell. The problem is if you type in a
> long sentance with no breaks, the <pre> will not allow it to wrap, and
> it'll make the table super wide. I'm wondering if there's a javascript
> function that will allow me to insert a \n every 80 characters? 
>  

Not built-in, no. If you build your own, you may want to refine it so 
that it breaks on the nearest space rather than exactly at 80.

Triche





More information about the Javascript mailing list