设为首页收藏本站

Scripts 学盟

 找回密码
 加入学盟

QQ登录

只需一步,快速开始

查看: 4326|回复: 6
打印 上一主题 下一主题

ECSHOP transport.js 与 jQuery 的兼容问题 [复制链接]

Rank: 9Rank: 9Rank: 9

跳转到指定楼层
1#
莺子 发表于 2011-6-30 11:01:32 |只看该作者 |倒序浏览
  1. <div id="preview">
  2.                             <div class="jqzoom" id="focuscont" >
  3.                                                                         <div id="focuscont1"  style="display:none">
  4.                                         <a href="gallery.php?id=203&amp;img=308" target="_blank"><img src="images/201106/goods_img/203_P_1307416283056.jpg"  width="320" height="380" align="middle"  onload="javascript:DrawImage(this);"/></a>
  5.                                         </div>
  6.                                                                         <div id="focuscont2"  style="display:none">
  7.                                         <a href="gallery.php?id=203&amp;img=309" target="_blank"><img src="images/201106/goods_img/203_P_1307416283074.jpg"  width="320" height="380" align="middle"  onload="javascript:DrawImage(this);"/></a>
  8.                                         </div>
  9.                                                                         <div id="focuscont3"  style="display:none">
  10.                                         <a href="gallery.php?id=203&amp;img=310" target="_blank"><img src="images/201106/goods_img/203_P_1307416283250.jpg"  width="320" height="380" align="middle"  onload="javascript:DrawImage(this);"/></a>
  11.                                         </div>
  12.                                                                         <div id="focuscont4"  style="display:none">
  13.                                         <a href="gallery.php?id=203&amp;img=311" target="_blank"><img src="images/201106/goods_img/203_P_1307416283529.jpg"  width="320" height="380" align="middle"  onload="javascript:DrawImage(this);"/></a>
  14.                                         </div>
  15.                                                                         <div id="focuscont5"  style="display:none">

  16.                                         <a href="gallery.php?id=203&amp;img=312" target="_blank"><img src="images/201106/goods_img/203_P_1307416283968.jpg"  width="320" height="380" align="middle"  onload="javascript:DrawImage(this);"/></a>
  17.                                         </div>
  18.                                                                         <div id="focuscont6"  style="display:none">
  19.                                         <a href="gallery.php?id=203&amp;img=313" target="_blank"><img src="images/201106/goods_img/203_P_1307416283604.jpg"  width="320" height="380" align="middle"  onload="javascript:DrawImage(this);"/></a>
  20.                                         </div>
  21.                                                                         <div id="focuscont7"  style="display:none">
  22.                                         <a href="gallery.php?id=203&amp;img=314" target="_blank"><img src="images/201106/goods_img/203_P_1307416283627.jpg"  width="320" height="380" align="middle"  onload="javascript:DrawImage(this);"/></a>
  23.                                         </div>
  24.                                                             </div>
  25.                         <div id=spec-n5>
  26.                             <div class=control id=spec-left>
  27.                                 <img src="themes/commodity/images/left.gif" />
  28.                             </div>
  29.                             <div id=spec-list>
  30.                                 <ul id="focustab" class="list-h">
  31.                                                                         <li><a href="#go" target="_blank" name="1"><img src="images/201106/goods_img/203_P_1307416283056.jpg" /></a></li>
  32.                                                                         <li><a href="#go" target="_blank" name="2"><img src="images/201106/goods_img/203_P_1307416283074.jpg" /></a></li>
  33.                                                                         <li><a href="#go" target="_blank" name="3"><img src="images/201106/goods_img/203_P_1307416283250.jpg" /></a></li>
  34.                                                                         <li><a href="#go" target="_blank" name="4"><img src="images/201106/goods_img/203_P_1307416283529.jpg" /></a></li>
  35.                                                                         <li><a href="#go" target="_blank" name="5"><img src="images/201106/goods_img/203_P_1307416283968.jpg" /></a></li>
  36.                                                                         <li><a href="#go" target="_blank" name="6"><img src="images/201106/goods_img/203_P_1307416283604.jpg" /></a></li>
  37.                                                                         <li><a href="#go" target="_blank" name="7"><img src="images/201106/goods_img/203_P_1307416283627.jpg" /></a></li>
  38.                                                                     </ul>
  39.                             </div>
  40.                             <div class=control id=spec-right>
  41.                                 <img src="themes/commodity/images/right.gif" />
  42.                             </div>
  43.                             <script>initAutoFocus();</script>
  44.                         </div>
  45.                     </div>
  46.                     <script type="text/javascript">
  47.                        $(function(){               
  48.                             $("#spec-list").jdMarquee({
  49.                                 deriction:"left",
  50.                                 width:294,
  51.                                 height:50,
  52.                                 step:2,
  53.                                 speed:4,
  54.                                 delay:10,
  55.                                 control:true,
  56.                                 _front:"#spec-right",
  57.                                 _back:"#spec-left"
  58.                             });
  59.                             $("#spec-list img").bind("mouseover",function(){
  60.                                 var src=$(this).attr("src");
  61.                                 $("#spec-n1 img").eq(0).attr({
  62.                                     src:src.replace("\/n5\/","\/n1\/"),
  63.                                     jqimg:src.replace("\/n5\/","\/n0\/")
  64.                                 });
  65.                                 $(this).css({
  66.                                     "border":"2px solid #ff6600",
  67.                                     "padding":"1px"
  68.                                 });
  69.                             }).bind("mouseout",function(){
  70.                                 $(this).css({
  71.                                     "border":"1px solid #ccc",
  72.                                     "padding":"2px"
  73.                                 });
  74.                             });                               
  75.                         })
  76.                         </script>
复制代码
这代码是我要的效果,但会跟下面的一个JS冲突,有下面的JS上面就不能起作用,帮我看看是哪里冲突了
  1. /**
  2. * @file            transport.js
  3. * @description     用于支持AJAX的传输类。
  4. * @author          ECShop R&D Team ( [url]http://www.ecshop.com/[/url] )
  5. * @date            2007-03-08 Wednesday
  6. * @license         Licensed under the Academic Free License 2.1 [url]http://www.opensource.org/licenses/afl-2.1.php[/url]
  7. * @version         1.0.20070308
  8. **/

  9. var Transport =
  10. {
  11.   /* *
  12.   * 存储本对象所在的文件名。
  13.   *
  14.   * @static
  15.   */
  16.   filename : "transport.js",

  17.   /* *
  18.   * 存储是否进入调试模式的开关,打印调试消息的方式,换行符,调试用的容器的ID。
  19.   *
  20.   * @private
  21.   */
  22.   debugging :
  23.   {
  24.     isDebugging : 0,
  25.     debuggingMode : 0,
  26.     linefeed : "",
  27.     containerId : 0
  28.   },

  29.   /* *
  30.   * 设置调试模式以及打印调试消息方式的方法。
  31.   *
  32.   * @public
  33.   * @param   {int}   是否打开调试模式      0:关闭,1:打开
  34.   * @param   {int}   打印调试消息的方式    0:alert,1:innerHTML
  35.   *
  36.   */
  37.   debug : function (isDebugging, debuggingMode)
  38.   {
  39.     this.debugging =
  40.     {
  41.       "isDebugging" : isDebugging,
  42.       "debuggingMode" : debuggingMode,
  43.       "linefeed" : debuggingMode ? "<br />" : "\n",
  44.       "containerId" : "dubugging-container" + new Date().getTime()
  45.     };
  46.   },

  47.   /* *
  48.   * 传输完毕后自动调用的方法,优先级比用户从run()方法中传入的回调函数高。
  49.   *
  50.   * @public
  51.   */
  52.   onComplete : function ()
  53.   {
  54.   },

  55.   /* *
  56.   * 传输过程中自动调用的方法。
  57.   *
  58.   * @public
  59.   */
  60.   onRunning : function ()
  61.   {
  62.   },

  63.   /* *
  64.   * 调用此方法发送HTTP请求。
  65.   *
  66.   * @public
  67.   * @param   {string}    url             请求的URL地址
  68.   * @param   {mix}       params          发送参数
  69.   * @param   {Function}  callback        回调函数
  70.   * @param   {string}    ransferMode     请求的方式,有"GET"和"POST"两种
  71.   * @param   {string}    responseType    响应类型,有"JSON"、"XML"和"TEXT"三种
  72.   * @param   {boolean}   asyn            是否异步请求的方式
  73.   * @param   {boolean}   quiet           是否安静模式请求
  74.   */
  75.   run : function (url, params, callback, transferMode, responseType, asyn, quiet)
  76.   {
  77.     /* 处理用户在调用该方法时输入的参数 */
  78.     params = this.parseParams(params);
  79.     transferMode = typeof(transferMode) === "string"
  80.     && transferMode.toUpperCase() === "GET"
  81.     ? "GET"
  82.     : "POST";

  83.     if (transferMode === "GET")
  84.     {
  85.       var d = new Date();

  86.       url += params ? (url.indexOf("?") === - 1 ? "?" : "&") + params : "";
  87.       url = encodeURI(url) + (url.indexOf("?") === - 1 ? "?" : "&") + d.getTime() + d.getMilliseconds();
  88.       params = null;
  89.     }

  90.     responseType = typeof(responseType) === "string" && ((responseType = responseType.toUpperCase()) === "JSON" || responseType === "XML") ? responseType : "TEXT";
  91.     asyn = asyn === false ? false : true;

  92.     /* 处理HTTP请求和响应 */
  93.     var xhr = this.createXMLHttpRequest();

  94.     try
  95.     {
  96.       var self = this;

  97.       if (typeof(self.onRunning) === "function" && !quiet)
  98.       {
  99.         self.onRunning();
  100.       }

  101.       xhr.open(transferMode, url, asyn);

  102.       if (transferMode === "POST")
  103.       {
  104.         xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  105.       }

  106.       if (asyn)
  107.       {
  108.         xhr.onreadystatechange = function ()
  109.         {
  110.           if (xhr.readyState == 4)
  111.           {
  112.             switch ( xhr.status )
  113.             {
  114.               case 0:
  115.               case 200: // OK!
  116.                 /*
  117.                  * If the request was to create a new resource
  118.                  * (such as post an item to the database)
  119.                  * You could instead return a status code of '201 Created'
  120.                  */

  121.                 if (typeof(self.onComplete) === "function")
  122.                 {
  123.                   self.onComplete();
  124.                 }

  125.                 if (typeof(callback) === "function")
  126.                 {
  127.                   callback.call(self, self.parseResult(responseType, xhr), xhr.responseText);
  128.                 }
  129.               break;

  130.               case 304: // Not Modified
  131.                 /*
  132.                  * This would be used when your Ajax widget is
  133.                  * checking for updated content,
  134.                  * such as the Twitter interface.
  135.                  */
  136.               break;

  137.               case 400: // Bad Request
  138.                 /*
  139.                  * A bit like a safety net for requests by your JS interface
  140.                  * that aren't supported on the server.
  141.                  * "Your browser made a request that the server cannot understand"
  142.                  */
  143.                  alert("XmlHttpRequest status: [400] Bad Request");
  144.               break;

  145.               case 404: // Not Found
  146.                 alert("XmlHttpRequest status: [404] \nThe requested URL "+url+" was not found on this server.");
  147.               break;

  148.               case 409: // Conflict
  149.                 /*
  150.                  * Perhaps your JavaScript request attempted to
  151.                  * update a Database record
  152.                  * but failed due to a conflict
  153.                  * (eg: a field that must be unique)
  154.                  */
  155.               break;

  156.               case 503: // Service Unavailable
  157.                 /*
  158.                  * A resource that this request relies upon
  159.                  * is currently unavailable
  160.                  * (eg: a file is locked by another process)
  161.                  */
  162.                  alert("XmlHttpRequest status: [503] Service Unavailable");
  163.               break;

  164.               default:
  165.                 alert("XmlHttpRequest status: [" + xhr.status + "] Unknow status.");
  166.             }

  167.             xhr = null;
  168.           }
  169.         }
  170.         if (xhr != null) xhr.send(params);
  171.       }
  172.       else
  173.       {
  174.         if (typeof(self.onRunning) === "function")
  175.         {
  176.           self.onRunning();
  177.         }

  178.         xhr.send(params);

  179.         var result = self.parseResult(responseType, xhr);
  180.         //xhr = null;

  181.         if (typeof(self.onComplete) === "function")
  182.         {
  183.           self.onComplete();
  184.         }
  185.         if (typeof(callback) === "function")
  186.         {
  187.           callback.call(self, result, xhr.responseText);
  188.         }

  189.         return result;
  190.       }
  191.     }
  192.     catch (ex)
  193.     {
  194.       if (typeof(self.onComplete) === "function")
  195.       {
  196.         self.onComplete();
  197.       }

  198.       alert(this.filename + "/run() error:" + ex.description);
  199.     }
  200.   },

  201.   /* *
  202.   * 如果开启了调试模式,该方法会打印出相应的信息。
  203.   *
  204.   * @private
  205.   * @param   {string}    info    调试信息
  206.   * @param   {string}    type    信息类型
  207.   */
  208.   displayDebuggingInfo : function (info, type)
  209.   {
  210.     if ( ! this.debugging.debuggingMode)
  211.     {
  212.       alert(info);
  213.     }
  214.     else
  215.     {

  216.       var id = this.debugging.containerId;
  217.       if ( ! document.getElementById(id))
  218.       {
  219.         div = document.createElement("DIV");
  220.         div.id = id;
  221.         div.style.position = "absolute";
  222.         div.style.width = "98%";
  223.         div.style.border = "1px solid #f00";
  224.         div.style.backgroundColor = "#eef";
  225.         var pageYOffset = document.body.scrollTop
  226.         || window.pageYOffset
  227.         || 0;
  228.         div.style.top = document.body.clientHeight * 0.6
  229.         + pageYOffset
  230.         + "px";
  231.         document.body.appendChild(div);
  232.         div.innerHTML = "<div></div>"
  233.         + "<hr style='height:1px;border:1px dashed red;'>"
  234.         + "<div></div>";
  235.       }

  236.       var subDivs = div.getElementsByTagName("DIV");
  237.       if (type === "param")
  238.       {
  239.         subDivs[0].innerHTML = info;
  240.       }
  241.       else
  242.       {
  243.         subDivs[1].innerHTML = info;
  244.       }
  245.     }
  246.   },

  247.   /* *
  248.   * 创建XMLHttpRequest对象的方法。
  249.   *
  250.   * @private
  251.   * @return      返回一个XMLHttpRequest对象
  252.   * @type    Object
  253.   */
  254.   createXMLHttpRequest : function ()
  255.   {
  256.     var xhr = null;

  257.     if (window.ActiveXObject)
  258.     {
  259.       var versions = ['Microsoft.XMLHTTP', 'MSXML6.XMLHTTP', 'MSXML5.XMLHTTP', 'MSXML4.XMLHTTP', 'MSXML3.XMLHTTP', 'MSXML2.XMLHTTP', 'MSXML.XMLHTTP'];

  260.       for (var i = 0; i < versions.length; i ++ )
  261.       {
  262.         try
  263.         {
  264.           xhr = new ActiveXObject(versions[i]);
  265.           break;
  266.         }
  267.         catch (ex)
  268.         {
  269.           continue;
  270.         }
  271.       }
  272.     }
  273.     else
  274.     {
  275.       xhr = new XMLHttpRequest();
  276.     }

  277.     return xhr;
  278.   },

  279.   /* *
  280.   * 当传输过程发生错误时将调用此方法。
  281.   *
  282.   * @private
  283.   * @param   {Object}    xhr     XMLHttpRequest对象
  284.   * @param   {String}    url     HTTP请求的地址
  285.   */
  286.   onXMLHttpRequestError : function (xhr, url)
  287.   {
  288.     throw "URL: " + url + "\n"
  289.     +  "readyState: " + xhr.readyState + "\n"
  290.     + "state: " + xhr.status + "\n"
  291.     + "headers: " + xhr.getAllResponseHeaders();
  292.   },

  293.   /* *
  294.   * 对将要发送的参数进行格式化。
  295.   *
  296.   * @private
  297.   * @params {mix}    params      将要发送的参数
  298.   * @return 返回合法的参数
  299.   * @type string
  300.   */
  301.   parseParams : function (params)
  302.   {
  303.     var legalParams = "";
  304.     params = params ? params : "";

  305.     if (typeof(params) === "string")
  306.     {
  307.       legalParams = params;
  308.     }
  309.     else if (typeof(params) === "object")
  310.     {
  311.       try
  312.       {
  313.         legalParams = "JSON=" + params.toJSONString();
  314.       }
  315.       catch (ex)
  316.       {
  317.         alert("Can't stringify JSON!");
  318.         return false;
  319.       }
  320.     }
  321.     else
  322.     {
  323.       alert("Invalid parameters!");
  324.       return false;
  325.     }

  326.     if (this.debugging.isDebugging)
  327.     {
  328.       var lf = this.debugging.linefeed,
  329.       info = "[Original Parameters]" + lf + params + lf + lf
  330.       + "[Parsed Parameters]" + lf + legalParams;

  331.       this.displayDebuggingInfo(info, "param");
  332.     }

  333.     return legalParams;
  334.   },

  335.   /* *
  336.   * 对返回的HTTP响应结果进行过滤。
  337.   *
  338.   * @public
  339.   * @params   {mix}   result   HTTP响应结果
  340.   * @return  返回过滤后的结果
  341.   * @type string
  342.   */
  343.   preFilter : function (result)
  344.   {
  345.     return result.replace(/\xEF\xBB\xBF/g, "");
  346.   },

  347.   /* *
  348.   * 对返回的结果进行格式化。
  349.   *
  350.   * @private
  351.   * @return 返回特定格式的数据结果
  352.   * @type mix
  353.   */
  354.   parseResult : function (responseType, xhr)
  355.   {
  356.     var result = null;

  357.     switch (responseType)
  358.     {
  359.       case "JSON" :
  360.         result = this.preFilter(xhr.responseText);
  361.         try
  362.         {
  363.           result = result.parseJSON();
  364.         }
  365.         catch (ex)
  366.         {
  367.           throw this.filename + "/parseResult() error: can't parse to JSON.\n\n" + xhr.responseText;
  368.         }
  369.         break;
  370.       case "XML" :
  371.         result = xhr.responseXML;
  372.         break;
  373.       case "TEXT" :
  374.         result = this.preFilter(xhr.responseText);
  375.         break;
  376.       default :
  377.         throw this.filename + "/parseResult() error: unknown response type:" + responseType;
  378.     }

  379.     if (this.debugging.isDebugging)
  380.     {
  381.       var lf = this.debugging.linefeed,
  382.       info = "[Response Result of " + responseType + " Format]" + lf
  383.       + result;

  384.       if (responseType === "JSON")
  385.       {
  386.         info = "[Response Result of TEXT Format]" + lf
  387.         + xhr.responseText + lf + lf
  388.         + info;
  389.       }

  390.       this.displayDebuggingInfo(info, "result");
  391.     }

  392.     return result;
  393.   }
  394. };

  395. /* 定义两个别名 */
  396. var Ajax = Transport;
  397. Ajax.call = Transport.run;

  398. /*
  399.     json.js
  400.     2007-03-06

  401.     Public Domain

  402.     This file adds these methods to JavaScript:

  403.         array.toJSONString()
  404.         boolean.toJSONString()
  405.         date.toJSONString()
  406.         number.toJSONString()
  407.         object.toJSONString()
  408.         string.toJSONString()
  409.             These methods produce a JSON text from a JavaScript value.
  410.             It must not contain any cyclical references. Illegal values
  411.             will be excluded.

  412.             The default conversion for dates is to an ISO string. You can
  413.             add a toJSONString method to any date object to get a different
  414.             representation.

  415.         string.parseJSON(filter)
  416.             This method parses a JSON text to produce an object or
  417.             array. It can throw a SyntaxError exception.

  418.             The optional filter parameter is a function which can filter and
  419.             transform the results. It receives each of the keys and values, and
  420.             its return value is used instead of the original value. If it
  421.             returns what it received, then structure is not modified. If it
  422.             returns undefined then the member is deleted.

  423.             Example:

  424.             // Parse the text. If a key contains the string 'date' then
  425.             // convert the value to a date.

  426.             myData = text.parseJSON(function (key, value) {
  427.                 return key.indexOf('date') >= 0 ? new Date(value) : value;
  428.             });

  429.     It is expected that these methods will formally become part of the
  430.     JavaScript Programming Language in the Fourth Edition of the
  431.     ECMAScript standard in 2008.
  432. */

  433. // Augment the basic prototypes if they have not already been augmented.

  434. if ( ! Object.prototype.toJSONString) {
  435.     Array.prototype.toJSONString = function () {
  436.         var a = ['['], // The array holding the text fragments.
  437.             b,         // A boolean indicating that a comma is required.
  438.             i,         // Loop counter.
  439.             l = this.length,
  440.             v;         // The value to be stringified.

  441.         function p(s) {

  442.             // p accumulates text fragments in an array. It inserts a comma before all
  443.             // except the first fragment.

  444.             if (b) {
  445.               a.push(',');
  446.             }
  447.             a.push(s);
  448.             b = true;
  449.         }

  450.         // For each value in this array...

  451.         for (i = 0; i < l; i ++) {
  452.             v = this[i];
  453.             switch (typeof v) {

  454.             // Values without a JSON representation are ignored.

  455.             case 'undefined':
  456.             case 'function':
  457.             case 'unknown':
  458.                 break;

  459.             // Serialize a JavaScript object value. Ignore objects thats lack the
  460.             // toJSONString method. Due to a specification error in ECMAScript,
  461.             // typeof null is 'object', so watch out for that case.

  462.             case 'object':
  463.                 if (v) {
  464.                     if (typeof v.toJSONString === 'function') {
  465.                         p(v.toJSONString());
  466.                     }
  467.                 } else {
  468.                     p("null");
  469.                 }
  470.                 break;

  471.             // Otherwise, serialize the value.

  472.             default:
  473.                 p(v.toJSONString());
  474.             }
  475.         }

  476.         // Join all of the fragments together and return.

  477.         a.push(']');
  478.         return a.join('');
  479.     };

  480.     Boolean.prototype.toJSONString = function () {
  481.         return String(this);
  482.     };

  483.     Date.prototype.toJSONString = function () {

  484.         // Ultimately, this method will be equivalent to the date.toISOString method.

  485.         function f(n) {

  486.             // Format integers to have at least two digits.

  487.             return n < 10 ? '0' + n : n;
  488.         }

  489.         return '"' + this.getFullYear() + '-' +
  490.                 f(this.getMonth() + 1) + '-' +
  491.                 f(this.getDate()) + 'T' +
  492.                 f(this.getHours()) + ':' +
  493.                 f(this.getMinutes()) + ':' +
  494.                 f(this.getSeconds()) + '"';
  495.     };

  496.     Number.prototype.toJSONString = function () {

  497.         // JSON numbers must be finite. Encode non-finite numbers as null.

  498.         return isFinite(this) ? String(this) : "null";
  499.     };

  500.     Object.prototype.toJSONString = function () {
  501.         var a = ['{'],  // The array holding the text fragments.
  502.             b,          // A boolean indicating that a comma is required.
  503.             k,          // The current key.
  504.             v;          // The current value.

  505.         function p(s) {

  506.             // p accumulates text fragment pairs in an array. It inserts a comma before all
  507.             // except the first fragment pair.

  508.             if (b) {
  509.                 a.push(',');
  510.             }
  511.             a.push(k.toJSONString(), ':', s);
  512.             b = true;
  513.         }

  514.         // Iterate through all of the keys in the object, ignoring the proto chain.

  515.         for (k in this) {
  516.             if (this.hasOwnProperty(k)) {
  517.                 v = this[k];
  518.                 switch (typeof v) {

  519.                 // Values without a JSON representation are ignored.

  520.                 case 'undefined':
  521.                 case 'function':
  522.                 case 'unknown':
  523.                     break;

  524.                 // Serialize a JavaScript object value. Ignore objects that lack the
  525.                 // toJSONString method. Due to a specification error in ECMAScript,
  526.                 // typeof null is 'object', so watch out for that case.

  527.                 case 'object':
  528.                     if (this !== window)
  529.                     {
  530.                       if (v) {
  531.                           if (typeof v.toJSONString === 'function') {
  532.                               p(v.toJSONString());
  533.                           }
  534.                       } else {
  535.                           p("null");
  536.                       }
  537.                     }
  538.                     break;
  539.                 default:
  540.                     p(v.toJSONString());
  541.                 }
  542.             }
  543.         }

  544.           // Join all of the fragments together and return.

  545.         a.push('}');
  546.         return a.join('');
  547.     };

  548.     (function (s) {

  549.         // Augment String.prototype. We do this in an immediate anonymous function to
  550.         // avoid defining global variables.

  551.         // m is a table of character substitutions.

  552.         var m = {
  553.             '\b': '\\b',
  554.             '\t': '\\t',
  555.             '\n': '\\n',
  556.             '\f': '\\f',
  557.             '\r': '\\r',
  558.             '"' : '\\"',
  559.             '\\': '\\\\'
  560.         };

  561.         s.parseJSON = function (filter) {

  562.             // Parsing happens in three stages. In the first stage, we run the text against
  563.             // a regular expression which looks for non-JSON characters. We are especially
  564.             // concerned with '()' and 'new' because they can cause invocation, and '='
  565.             // because it can cause mutation. But just to be safe, we will reject all
  566.             // unexpected characters.

  567.             try {
  568.                 if (/^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/.
  569.                         test(this)) {

  570.                     // In the second stage we use the eval function to compile the text into a
  571.                     // JavaScript structure. The '{' operator is subject to a syntactic ambiguity
  572.                     // in JavaScript: it can begin a block or an object literal. We wrap the text
  573.                     // in parens to eliminate the ambiguity.

  574.                     var j = eval('(' + this + ')');

  575.                     // In the optional third stage, we recursively walk the new structure, passing
  576.                     // each name/value pair to a filter function for possible transformation.

  577.                     if (typeof filter === 'function') {

  578.                         function walk(k, v) {
  579.                             if (v && typeof v === 'object') {
  580.                                 for (var i in v) {
  581.                                     if (v.hasOwnProperty(i)) {
  582.                                         v[i] = walk(i, v[i]);
  583.                                     }
  584.                                 }
  585.                             }
  586.                             return filter(k, v);
  587.                         }

  588.                         j = walk('', j);
  589.                     }
  590.                     return j;
  591.                 }
  592.             } catch (e) {

  593.             // Fall through if the regexp test fails.

  594.             }
  595.             throw new SyntaxError("parseJSON");
  596.         };

  597.         s.toJSONString = function () {

  598.           // If the string contains no control characters, no quote characters, and no
  599.           // backslash characters, then we can simply slap some quotes around it.
  600.           // Otherwise we must also replace the offending characters with safe
  601.           // sequences.

  602.           // add by weberliu @ 2007-4-2
  603.           var _self = this.replace("&", "%26");

  604.           if (/["\\\x00-\x1f]/.test(this)) {
  605.               return '"' + _self.replace(/([\x00-\x1f\\"])/g, function(a, b) {
  606.                   var c = m[b];
  607.                   if (c) {
  608.                       return c;
  609.                   }
  610.                   c = b.charCodeAt();
  611.                   return '\\u00' +
  612.                       Math.floor(c / 16).toString(16) +
  613.                       (c % 16).toString(16);
  614.               }) + '"';
  615.           }
  616.           return '"' + _self + '"';
  617.         };
  618.     })(String.prototype);
  619. }

  620. Ajax.onRunning  = showLoader;
  621. Ajax.onComplete = hideLoader;

  622. /* *
  623. * 显示载入信息
  624. */
  625. function showLoader()
  626. {
  627.   document.getElementsByTagName('body').item(0).style.cursor = "wait";

  628.   if (top.frames['header-frame'])
  629.   {
  630.     top.frames['header-frame'].document.getElementById("load-div").style.display = "block";
  631.   }
  632.   else
  633.   {
  634.     var obj = document.getElementById('loader');

  635.     if ( ! obj && process_request)
  636.     {
  637.       obj = document.createElement("DIV");
  638.       obj.id = "loader";
  639.       obj.innerHTML = process_request;

  640.       document.body.appendChild(obj);
  641.     }
  642.   }
  643. }

  644. /* *
  645. * 隐藏载入信息
  646. */
  647. function hideLoader()
  648. {
  649.   document.getElementsByTagName('body').item(0).style.cursor = "auto";
  650.   if (top.frames['header-frame'])
  651.   {
  652.     setTimeout(function(){top.frames['header-frame'].document.getElementById("load-div").style.display = "none"}, 10);
  653.   }
  654.   else
  655.   {
  656.     try
  657.     {
  658.       var obj = document.getElementById("loader");
  659.       obj.style.display = 'none';
  660.       document.body.removeChild(obj);
  661.     }
  662.     catch (ex)
  663.     {}
  664.   }
  665. }
复制代码
分享到: QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
分享分享0 收藏收藏0

管理员

超级大菜鸟

Rank: 9Rank: 9Rank: 9

2#
混混@普宁.中国 实名认证  发表于 2011-6-30 11:11:08 |只看该作者
太长了。。。

使用道具 举报

管理员

超级大菜鸟

Rank: 9Rank: 9Rank: 9

3#
混混@普宁.中国 实名认证  发表于 2011-6-30 12:10:39 |只看该作者
transport.js 中重载了 Object.prototype.toJSONString 方法  
与 jQuery 冲突了。。
考虑两者的使用场合都非常多,去修改兼容是比较不靠谱的

暂时用
  1. $(function(){   
  2.         window.__Object_toJSONString = Object.prototype.toJSONString;
  3.         delete Object.prototype.toJSONString;
  4.     $("#spec-list").jdMarquee({
  5.         deriction:"left",
  6.         width:294,
  7.         height:50,
  8.         step:2,
  9.         speed:4,
  10.         delay:10,
  11.         control:true,
  12.         _front:"#spec-right",
  13.         _back:"#spec-left"
  14.     });
  15.     $("#spec-list img").bind("mouseover",function(){
  16.         var src=$(this).attr("src");
  17.         $("#spec-n1 img").eq(0).attr({
  18.             src:src.replace("\/n5\/","\/n1\/"),
  19.             jqimg:src.replace("\/n5\/","\/n0\/")
  20.         });
  21.         $(this).css({
  22.             "border":"2px solid #ff6600",
  23.             "padding":"1px"
  24.         });
  25.     }).bind("mouseout",function(){
  26.         $(this).css({
  27.             "border":"1px solid #ccc",
  28.             "padding":"2px"
  29.         });
  30.     });                                
  31. });
复制代码
后续如果在当前页面中遇到别的问题,再作研究

使用道具 举报

Rank: 9Rank: 9Rank: 9

4#
浴火凤凰 发表于 2011-6-30 13:59:50 |只看该作者
那个JS好强大啊!!!

使用道具 举报

Rank: 9Rank: 9Rank: 9

5#
莺子 发表于 2011-6-30 14:21:19 |只看该作者
混混很强大,期待你的兼容,让我们学盟名扬ECSHOP,哈哈

使用道具 举报

管理员

超级大菜鸟

Rank: 9Rank: 9Rank: 9

6#
混混@普宁.中国 实名认证  发表于 2011-7-1 00:49:10 |只看该作者
修改 jQuery 或者 修改 transport.js 对于 ecshop 项目来说都是自找麻烦的事情。。。

还在在特定页面,设法绕过避开好了。。

使用道具 举报

Rank: 8Rank: 8

7#
那个谁 发表于 2011-7-1 14:31:23 |只看该作者
mark

使用道具 举报

您需要登录后才可以回帖 登录 | 加入学盟

手机版|Scripts 学盟   |

GMT+8, 2024-5-2 20:05 , Processed in 1.058505 second(s), 11 queries .

Powered by Discuz! X2

© 2001-2011 Comsenz Inc.

回顶部