开发者

How to Wrap unspaces word for Opera Browser

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; 
    fo开发者_开发百科nt-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.


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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜