Discuz! 发帖换行兼容方案(换行丢失问题解决)

Discuz! 发帖换行兼容方案(换行丢失问题解决)

Discuz!在发帖时,经常出现回车换行失效

故障解决

找到static/js/bbcode.js

搜索

if((allowhtml && fetchCheckbox('htmlon')) || trim(str) == '') {
    for(i in EXTRAFUNC['html2bbcode']) {
        EXTRASTR = str;
        try {
            eval('str = ' + EXTRAFUNC['html2bbcode'][i] + '()');
        } catch(e) {}
    }
    str = str.replace(/<img[^>]+smilieid=(["']?)(\d+)(\1)[^>]*>/ig, function($1, $2, $3) {return smileycode($3);});
    str = str.replace(/<img([^>]*aid=[^>]*)>/ig, function($1, $2) {return imgtag($2);});
    return str;
}

添加

var divPos = strpos(str,"<div>");
if(divPos > 0 ){
    if(divPos > 4 && str.substr(divPos - 4,4) == '</p>'){}
    else{
        str = str.substr(0,divPos) + '<br>'+ str.substr(divPos);
    }
}


分享到 :
相关推荐