tags:

views:

145

answers:

1

I am currently testing this function in all browser using php.

<style>
#preview_desc{
    text-wrap: suppress;
    word-break: break-all;
    word-wrap: break-word; /* IE>=5.5 */
    white-space: -moz-pre-wrap; /* For Fx<=2 */   
    white-space: pre-wrap; /* Fx>3, Opera>8, Safari>3 */
    white-space: -o-pre-wrap; /* Opera 7 */
    white-space: pre-line;
    width:158px; 
    padding-left:5px; 
    padding-right:5px; 
    line-height:12px; 
    font-family:'Arial', Helvetica, sans-serif; 
    font-size:11px; 
    text-align:justify;
    background:#f30000;
}
</style>

<div id="preview_desc" 
class="adlookmsg_box">
Refeforotherapplicationandcontainasdhlsakfhnaiufalsdufgnaloskdufglkjblfasug
</div>

However only in Opera browser that not process the wrapping or the unspace word. Please if any can help with this. Tks

--Edited-- note: sorry bout this appereance.

+2  A: 

Hi Febri,

I am using Opera 10.10 also, I can regenerate your problem, but unfortunately I don't have good/proper answer, but a hack here. Do it If there is no other way. Put following codes to end of the document.

<script>
     x=document.getElementById("preview_desc");
     x.innerHTML=x.innerHTML.replace(/(.)/g,"$1\u200b");
</script>

It will put \u200b (Zero Width Space) character after every characters, so Opera would able to handle that..

UPDATE: Only add \u200b to long words, currently set as 10+, you may need to adjust it.

<script>
    x=document.getElementById("preview_desc");
    x.innerHTML=x.innerHTML.replace(/[\w]{10,}/g,function(x){return x.replace(/(.)/g,"$1\u200b");});
</script>
S.Mark
Hi S.MarkThanks for your answer. It is works fine. However, new problem occur, any style related to font e.g. <strong> or <u> is showing the tag name not showing the result.Why is that?
Febri
Oops! got it, So you have html tags inside "preview_desc", hold on please, I will update it to works only for long words.
S.Mark
Hi S.MarkIt work perfectly. Thank you so much. Hope you wouldn't mind if I'll ask you some other time.
Febri
You're welcome!
S.Mark
Hi Mark.. The solution that you give me, there is some little problem.Last time I tried the whole chars inside 1 tag, however, if I put the html tags at diff part of chars, the function isn't work.FYI, mine using tinyMCE for textarea.Tks.
Febri