I have a JavaScript function that returns a string. I want to write this string to an html page, but in a block-of-text format where I can specify the width. I’m currently using a read-only textarea, but I’m sure there’s a much better way. How would I do this?
Example:
String returned from javascript function:
The dog was lazy in the sun.
On the html page:
The dog was
lazy in the
sun.
Edit:
Sorry, I wasn’t being clear enough.
This javascript function could return any string, I don’t know what it could return.
So inside my html, I would do the following:
<script type="text/javascript" />
document.write(functionCall());
</script>
but I would like to format this like in the example above.
Unfortunately, wrapping this in <div> tags with the width attribute doesn’t work.
1 Answer