如何解决ecshop中jquery和transport之间的冲突

要在ecshop中使用lightbox,lightbox是用的jQuery,但在使用的时候有冲突:

Message: Object doesn't support this property or method
Line: 608
Char: 13
Code: 0
URI: http://localhost:8094/js/transport.js

在网上找了一下,解决方案如下:
把ecshop中的transport.js中的Object.prototype.toJSONString方法(大概在587行)注释掉,因为就是这个方法和jquery冲突了。
再找一个替换的方法,加在transport.js的最后:

function obj2str(o){   
    var r = [];   
    if(typeof o =="string") return "\""+o.replace(/([\'\"\\])/g,"\\$1").replace(/(\n)/g,"\\n").replace(/(\r)/g,"\\r").replace(/(\t)/g,"\\t")+"\"";   
    if(typeof o =="undefined") return "undefined";   
    if(typeof o == "object"){   
        if(o===null) return "null";   
        else if(!o.sort){   
            for(var i in o)   
                r.push("\""+i+"\""+":"+obj2str(o[i]))   
            r="{"+r.join()+"}"  
        }else{   
            for(var i =0;i<o.length;i++)   
                r.push(obj2str(o[i]))   
            r="["+r.join()+"]"  
        }   
        return r;   
    }   
    return o.toString();   
}

事情还没有完呢,要把程序中所有用到toJSONString的地方用obj2str去替换,查找文件:*.js;*.dwt;*.lbi中的toJSONString字符串,用obj2str去替换。


Leave Your Comment

Your email will not be published or shared. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="">

*
请输入图片中的字符以验证你并非垃圾机器人. 点击图片收听验证码的语音版.
点击这里收听此验证码的语音版本