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 stackover
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.
function GetWrapedText(text, maxlength) {
var resultText = [""];
var len = text.length;
if (maxlength >= len) {
return text;
}
else {
var totalStrCount = parseInt(len / maxlength);
if (len % maxlength != 0) {
totalStrCount++
}
for (var i = 0; i < totalStrCount; i++) {
if (i == totalStrCount - 1) {
resultText.push(text);
}
else {
var strPiece = text.substring(0, maxlength - 1);
resultText.push(strPiece);
resultText.push("<br>");
text = text.substring(maxlength - 1, text.length);
}
}
}
return resultText.join("");
}