views:

1214

answers:

2

Hi,

I have tinymce editor(textarea) and one div. Whenever i type inside the text editor, it shows at the preview div which is (200px) in real time which is looks alike stackoverflow preview.

What I want to achieve is, if we type one words without space and if exceed 200px, I want to wrap it to the next line.

I tried to find it and I didn't find the solution yet. I tried this solution which i found here

.preview_desc 
{   
    word-wrap: break-word; /* IE>=5.5 */  
    white-space: pre; /* IE>=6 */  
    white-space: -moz-pre-wrap; /* For Fx<=2 */   
    white-space: pre-wrap; /* Fx>3, Opera>8, Safari>3 */ 
}

It doesn't work well in IE7. It added the left and right space. So my div become so wide like the following image

http://img38.imageshack.us/img38/2650/ie7g.jpg

In IE8, which is correct looks is like this.

img35.imageshack.us/img35/3915/ie8a.jpg (Please add http:// and view)

Opera 10 is not totally working also.

And then I have line count js also. Which is

var height = document.getElementById('divpreview').clientHeight;
var lines = Math.round(height / 10); 
document.getElementById('lines').innerHTML = lines;  
if(document.getElementById('divpreview').innerHTML == "")
{
     document.getElementById('lines').innerHTML = 0;  
}

If we use the above css code, it starting count from line 2 in all browsers except IE8 and 7.

I only want to works on all latest browser which is FF2,3,IE7,IE8,Safari,Chrome,Opera (latest).

Please help me out. Thanks.

+1  A: 

I may be misunderstanding your issue, but it seems like all you need is a bit of CSS, specifically a max-width (for all the non-idiotic browsers) and a width with a wacky IE expression (for IE).

For instance

max-width:200px;
_width:expression(document.body.clientWidth > 200? "200px": "auto" );

When you combine that with the CSS you already have, it seems like it should work.

machineghost
Hi machineghost,I just tested. t doesn't work. IE7 still breaks the width like what i show in above screenshot. I don't know why though. IE8 is fine. Then, opera 10 doesn't wrap totally. Any idea to help me out? Thanks.
spotlightsnap
For the IE thing you might want to try: overflow:hidden;. It's hard to say exactly what your issue is though without being able to see it (if you can expose a sample page that shows the issue on the web somewhere that'd be more helpful), but basically this just sounds like a CSS layout issue. However, because of all the factors involved, those kinds of issues can be very tricky to debug, so I'd also recommend removing as much as you can around the problem, so that you just have a page with the problem elements and nothing else. This should make isolating the problem a lot easier.
machineghost
(what I mean by "because of all the factors involved is", is that the layout of an individual element is affected by the layout of its parent, its parent's parent, its parent's parent's parent, .... plus the layout of any sibling elements, plus the layout of any child elements. A CSS style defined for any one of those could be responsible for something weird you see in the original element's layout, so it's very tricky to figure out what exactly is causing the things you see. If however you can make a simple page with just the problem elements, you can remove all those potential factors.)
machineghost
A: 

@Natrium: I've got problem same like you regarding text-wrap. However in IE7 I found the solution. Add this css code into your table properties: table-layout:fixed; this should solve the problem.

However, I'm also trying using opera 10.10 (latest ver) its doesn't wrap at all. It seems that opera doesn't support any of this function. Correct me if i'm wrong (just newbie) :D

Febri