账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    畅言评论代码与discuz外部调用代码冲突,如何解决
    52
    0

    问题:

    http://www.sddp.net/news-1335...

    畅言评论代码和discuz外部调用代码冲突,手机端不显示评论,将discuz的调用代码去掉之后,畅言评论就正常了,求解冲突原因及解决办法,代码如下:

    畅言评论代码:

    <div id="SOHUCS" sid="$article[aid]" ></div>
    <script type="text/javascript">
    (function() {
        var appid = 'cytTbjla6';
        var conf = 'prod_3aeea31d79efd447e8ef61a7ff76eb40';
        var width = window.innerWidth || document.documentElement.clientWidth;
        if (width < 960) {
            window.document.write('<script id="changyan_mobile_js" charset="utf-8" type="text/javascript" src="https://changyan.sohu.com/upload/mobile/wap-js/changyan_mobile.js?client_id=' + appid + '&conf=' + conf + '"><\/script>');
        } else {
            var loadJs = function(d, a) {
                var c = document.getElementsByTagName("head")[0] || document.head || document.documentElement;
                var b = document.createElement("script");
                b.setAttribute("type", "text/javascript");
                b.setAttribute("charset", "UTF-8");
                b.setAttribute("src", d);
                if (typeof a === "function") {
                    if (window.attachEvent) {
                        b.onreadystatechange = function() {
                            var e = b.readyState;
                            if (e === "loaded" || e === "complete") {
                                b.onreadystatechange = null;
                                a()
                            }
                        }
                    } else {
                        b.onload = a
                    }
                }
                c.appendChild(b)
            };
            loadJs("https://changyan.sohu.com/upload/changyan.js",
            function() {
                window.changyan.api.config({
                    appid: appid,
                    conf: conf
                })
            });
        }
    })();
    </script>

    Discuz外部调用代码:

    <script type="text/javascript" src="http://bbs.sddp.net/api.php?mod=js&bid=495"></script>

    开始以为是document.write的原因,但是把畅言评论代码改成jquery写入,能将js写入到页面,但评论的html依然没有出来:

    if (width < 960) {
    var changyanjs = document.createElement('script');
    changyanjs.type = 'text/jacascript';changyanjs.id = 'changyan_mobile_js';changyanjs.src = 'https://changyan.sohu.com/upload/mobile/wap-js/changyan_mobile.js?client_id=cytTbjla6&conf=prod_3aeea31d79efd447e8ef61a7ff76eb40';
    jQuery('#SOHUCS').append(changyanjs)
    }

    请问到底是哪里冲突呢?求解

    0
    打赏
    收藏
    点击回答
        全部回答
    • 0
    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部