切割器
function loginBoxHeightChange() {
var textarea = document.getElementById('tx');
// textarea.style.height = textarea.scrollHeight + 'px'
textarea.style.overflowY = 'hidden'
textarea.style.resize = 'none'
textarea.style.backgroundColor = '#89bde5'
textarea.style.border = 'none'
textarea.style.textDecoration = 'underline';
textarea.readOnly = true;
var newTextarea=spliter(textarea.innerHTML,20)
var array= newTextarea.split("\n")
if(array.length>3)
{
textarea.innerHTML=array[0]+" "+array[1]+" "+array[2].substring(0,19)+"...";
}else{
textarea.innerHTML=newTextarea;
}
}
function spliter(text, max) {
var strs = new Array();
strs = text.split(' ');
var result = ''
for (var n = 0; n < strs.length; n++) {
result += splitMultiLine(strs[n], max);
};
return result;
}
function splitMultiLine(x, max) {
var strArray = '';
var num = Math.ceil(x.length / max);
var array = new Array();
for (var i = 0; i < num - 1; i++) {
array[i] = x.substring(max * i, max * (i + 1));
strArray += array[i] + ' ';
}
array[num - 1] = x.substring(max * (num - 1));
strArray += array[num - 1] + ' ';
return strArray;
}