CSDN 留言版的引用留言功能是怎么做的?
大虾能否给小弟分析下?

解决方案 »

  1.   

    简单来说 用javascript,当点击引用时,得到相应div中的文本内容 并将内容放入到文本框
      

  2.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>jiaban!~</title></head><body>
    <div id="ss">你好啊<br>
    好个屁,今天又加班,你列<br>
    都一样 - _ -!<br>
    OOXXOO  .............
    </div>
    <input  value="引用" type="button" onclick="yinyong()" />
    <div id="xxooxx"><div>
    <script>
    var $ = function(id){return document.getElementById(id);}
    function yinyong(){
    $('xxooxx').innerHTML = "<fieldset><legend>周末你加班吗</legend>"+$('ss').innerHTML+"</fieldset>"
    }
    </script>
    </body>
    </html>
      

  3.   

    <a onclick="try{Quote(2);}catch(ex){};return false" class="gr" href="javascript:;">引用</a>
    function Quote(layer) {
        var replyframe = $("replyframe");
        if (!replyframe) {
            return;
        }
        var editor = replyframe.contentWindow.document.getElementById("tb_ReplyBody___Editor");
        updateReplyItems();
        var text = reply_items[layer].body.innerHTML;
        text = text.replace(/<pre>[\s\S]*?<\/pre>/g, function ($0) {return $0.replace(/ /g, "&nbsp;");});
        text = text.replace(/<\/dt>/gi, "\r\n").replace(/\s*<br\s*\/?>\s*/gi, "\r\n").replace(/<[^>]+>/g, "").replace(/&(lt|gt|quoted|nbsp);/gi, function ($0, $1) {return {lt: "<", gt: ">", quoted: "\"", nbsp: " "}[$1.toLowerCase()];});
        text = text.replace(/^(\s+\r?\n)+/, "").replace(/^([\s\S]{200})([\s\S]*)$/, "$1\u2026\u2026").replace(/\s+$/, "");
        editor.value = "";
        window.location.href = "#replyachor";
        editor.focus();
    }
      

  4.   

    应该是用插件自定义了[Quote]吧,显示的时候进行解析。
      

  5.   

    1。改正了3楼的一个错误;
    2。在3楼的基础上又新加了个功能,若字符在40(可自行修改)个以下,直接引用;否则,省略后边的字符。如下:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>jiaban!~</title>
    <script>
    var $ = function(id){return document.getElementById(id);}
    function yinYong(){
    var con=$('ss').innerHTML;
    con=con.length<40?con:con.substring(0,40)+"...";
    $('xx').innerHTML = "<fieldset><legend>周末你加班吗</legend>"+con+"</fieldset>";
    }
    </script>
    </head><body>
    <div id="ss">你好啊<br>
    好个屁,今天又加班,你列<br>
    都一样 - _ -!<br>
    OOXXOO  .............
    </div>
    <input  value="引用" type="button" onClick="yinYong()" />
    <div id="xx"></div></body>
    </html>