Text wraping

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
Monopoly
Forum Commoner
Posts: 41
Joined: Wed May 21, 2008 1:19 pm

Text wraping

Post by Monopoly »

First of all , I suck in client-side ...

I have written a simple guestbook , but there is a problem :

In the text-area if you write a long continous string , the output on the main guestbook page
is also a long string that makes the browser "stretch" and a scroll bar appears...

I was told to ask client-side proggers....

Any solutions???
matthijs
DevNet Master
Posts: 3360
Joined: Thu Oct 06, 2005 3:57 pm

Re: Text wraping

Post by matthijs »

The short answer: overflow:auto;

The longer answer/demo:

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>untitled</title>
    <!-- Date: 2008-06-04 -->
    <style type="text/css" media="screen">
        * { margin:0;padding:0; }
        body { background:#eee;}
        #box { width:300px;margin:100px auto;border:1px solid #bbb;background:#fff;overflow:auto;}
        p { margin:10px; }
    </style>
</head>
<body>
<div id="box">
    <p>bhjbjbjhhhhhhhhhhhhhhhhhhhhhhhccccccccccccccccciiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiddddddddddddddd</p>
</div>
</body>
</html>
If you want to somehow break the long strings to make them fit you'll need some javascript wizzardry. But I wouldn't go to that trouble. Your needs may be different off course
Monopoly
Forum Commoner
Posts: 41
Joined: Wed May 21, 2008 1:19 pm

Re: Text wraping

Post by Monopoly »

Well , I actually need to break long strings ...

Anybody please give me that javascript wizadry :mrgreen: !!
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Re: Text wraping

Post by Kieran Huggins »

You shouldn't be breaking user input at all.

Also, you should be limiting your questions to one thread.
matthijs
DevNet Master
Posts: 3360
Joined: Thu Oct 06, 2005 3:57 pm

Re: Text wraping

Post by matthijs »

Well, since you've expressed so much gratefulness for the help so far I bet people are in line to write something for you or help you google.
Post Reply