ecshop中jQuery冲突解决
鹰潭网站建设
www.diyphp.net
<span style="COLOR: rgb(0,0,0)">首要就是Ecshop的AJAX传输类,transport.js 中重写了object的对象原型,然后招致了与jq框架的抵触。
<span style="COLOR: rgb(0,0,0)">处理:
1. 删除transport.js中587行 - 636行中关于object.prototype.toJSONString的界说
2. 自界说一个办法用于object对象的json序列化
如下
- function obj2str(o)
- {
- //开端
- var r = [];
- if(typeof o =="string") return "\""+o.replace(/([\'\"[url=file://\\])/g,]\\])/g,"\\$1").replace(/(\n)/g,"\\n").replace(/(\r)/g,"\\r").replace(/(\t)/g,"\\t")+"\[/url]"";
- if(typeof o =="undefined") return "undefined";
- if(typeof o == "object"){
- if(o===null) return "null";
- else if(!o.sort){
- for(var i in o)
- {
- if(i!="toJSONString") //添加判别,肃清对object原型的界说参加到json中
- r.push("\""+i+"\""+":"+obj2str(o));
- }
- r="{"+r.join()+"}";
- }else{
- for(var i =0;i<o.length;i++)
- r.push(obj2str(o))
- r="["+r.join()+"]"
- }
- return r;
- }
- return o.toString();
- //完毕
- }
<span style="COLOR: rgb(0,0,0)">3. 在模板页和js剧本中一切关于 obj.toJSONString()的当地,一概交换为obj2str(obj)
<span style="COLOR: rgb(0,0,0)">4. 重写好后发现compare.js, 首要重写个中的准时器 功用。 将以下代码交换到compare.js中
- var Compare = new Object();
- Compare = {
- add : function(goodsId, goodsName, type)
- {
- var count = 0;
- for (var k in this.data)
- {
- if (typeof(this.data[k]) == "function")
- continue;
- if (this.data[k].t != type) {
- alert(goods_type_different.replace("%s", goodsName));
- return;
- }
- count++;
- }
- if (this.data[goodsId])
- {
- alert(exist.replace("%s",goodsName));
- return;
- }
- else
- {
- this.data[goodsId] = {n:goodsName,t:type};
- }
- this.save();
- this.init();
- },
- init : function(){
- this.data = new Object();
- var cookieValue = document.getCookie("compareItems");
- if (cookieValue != null) {
- this.data = cookieValue.parseJSON();
- }
- if (!this.compareBox)
- {
- this.compareBox = document.createElement("DIV");
- var submitBtn = document.createElement("INPUT");
- this.compareList = document.createElement("UL");
- this.compareBox.id = "compareBox";
- this.compareBox.style.display = "none";
- this.compareBox.style.top = "200px";
- this.compareBox.align = "center";
- this.compareList.id = "compareList";
- submitBtn.type = "button";
- submitBtn.value = button_compare;
- this.compareBox.appendChild(this.compareList);
- this.compareBox.appendChild(submitBtn);
- submitBtn.onclick = function() {
- var cookieValue = document.getCookie("compareItems");
- var obj = cookieValue.parseJSON();
- var url = document.location.href;
- url = url.substring(0,url.lastIndexOf('/')+1) + "compare.php";
- var i = 0;
- for(var k in obj)
- {
- if(typeof(obj[k])=="function")
- continue;
- if(i==0)
- url += "?goods[]=" + k;
- else
- url += "&goods[]=" + k;
- i++;
- }
- if(i<2)
- {
- alert(compare_no_goods);
- return ;
- }
- document.location.href = url;
- }
- document.body.appendChild(this.compareBox);
- }
- this.compareList.innerHTML = "";
- var self = this;
- for (var key in this.data)
- {
- if(typeof(this.data[key]) == "function")
- continue;
- var li = document.createElement("LI");
- var span = document.createElement("SPAN");
- span.style.overflow = "hidden";
- span.style.width = "100px";
- span.style.height = "20px";
- span.style.display = "block";
- span.innerHTML = this.data[key].n;
- li.appendChild(span);
- li.style.listStyle = "none";
- var delBtn = document.createElement("IMG");
- delBtn.src = "themes/default/images/drop.gif";
- delBtn.className = key;
- delBtn.onclick = function(){
- document.getElementById("compareList").removeChild(this.parentNode);
- delete self.data[this.className];
- self.save();
- self.init();
- }
- li.insertBefore(delBtn,li.childNodes[0]);
- this.compareList.appendChild(li);
- }
- if (this.compareList.childNodes.length > 0)
- {
- this.compareBox.style.display = "";
- this.timer = window.setInterval("flowdiv('compareBox')", 50);
- }
- else
- {
- this.compareBox.style.display = "none";
- window.clearInterval(this.timer);
- this.timer = 0;
- }
- },
- save : function()
- {
- var date = new Date();
- date.setTime(date.getTime() + 99999999);
- document.setCookie("compareItems", obj2str(this.data));
- },
- lastScrollY : 0
- }
- //用于准时器的主动滚动的层
- lastScrollY=0;
- function flowdiv(domid){
- var diffY;
- if (document.documentElement && document.documentElement.scrollTop)
- diffY = document.documentElement.scrollTop;
- else if (document.body)
- diffY = document.body.scrollTop
- else
- {/*Netscape stuff*/}
- //alert(diffY);
- percent=.1*(diffY-lastScrollY);
- if(percent>0) percent=Math.ceil(percent);
- else percent=Math.floor(percent);
- document.getElementById(domid).style.top=parseInt(document.getElementById(domid).style.top)+percent+"px";
- lastScrollY=lastScrollY+percent;
- //alert(lastScrollY);
- 1网站改版注意的问题
- 2网站备案所需材料
- 3 企业四网合一网站升级版3
- 4PHP/MYSQL 查询大数据/遍历表
- 5ecshop的数据字典
- 6玩具租赁系统功能列表
- 7Linux系统平安Shell剧本用于Linux系统的平安初始化剧本
- 8网站建设和营销带来的经济效益
- 9企业网站的优化现状
- 10网贷平台主要运营模式主要有两类---债权转让模式
- 11企业为啥要求权威的网站维护单位做官方网站呢?
- 12世界看到你-----微信公众平台
- 13企业为啥要权威的网站建设公司做官网呢?
- 14p2p网贷系统可分为三部分
- 15网站制作绝对不可以犯的编程错误
- 16玩具租赁电商平台是什么
- 17关于HTML5当时状况的若干关键
- 18百度算法更新,为什么站被降权?
- 19如何让您的网站盈利中发挥到极致
- 20魅妆社区项目开发文档
- 21有关,PHP.ini 性能优化
- 22房地产行业微信营销方案1
- 23上海天煜商业联盟成功上线
- 24企业为什么偏爱须要专业的网站构造单位做官方网站呢?
- 25PHP应用中常见文件如何操作
- 26阿里云服务器年终六折疯抢
- 27玩具租赁如何走出困境
- 28微信公众平台有什么好处
- 29有关MySQL分页
- 30网站策划的重要讨论
成都公司:成都市成华区建设南路160号1层9号
重庆公司:重庆市江北区红旗河沟华创商务大厦18楼