2013-04-24 192 views
7

我正在使用一个名为pull.js的JavaScript文件。它使用Ipad下拉刷新,但是,当我使用其他jQuery和JavaScript停止工作?这是给下面的未捕获的异常错误:Javascript错误未捕获异常

" Error: uncaught exception:

[Exception... "Not enough arguments" nsresult: "0x80570001 (NS_ERROR_XPC_NOT_ENOUGH_ARGS)" location: "JS frame :: pull.js :: anonymous :: line 26" data: no] "

我传递的这一内容的js文件:

var PULL = function() { 
    var content, 
     pullToRefresh, 
     refreshing, 
     contentStartY, 
     success, 
     start, 
     cancel, 
     startY, 
     track = false, 
     refresh = false; 

    var removeTransition = function() { 
     //content.style['-webkit-transition-duration'] = 0; 
    }; 
    return { 
     init: function(o) { 
      content = document.getElementById('content'); 
      pullToRefresh = document.getElementById('pull_to_refresh'); 
      refreshing = document.getElementById('refreshing'); 
      success = o.success; 
      start = o.start; 
      cancel = o.cancel; 

      document.body.addEventListener('touchstart', function(e) { 
       e.preventDefault(); 
       contentStartY = parseInt(content.style.top); 
       startY = e.touches[0].screenY; 
      }); 

      document.body.addEventListener('touchend', function(e) { 
       if(refresh) { 
        //content.style['-webkit-transition-duration'] = '.5s'; 
        content.style.top = '50px'; 

        pullToRefresh.style.display = 'none'; 
        refreshing.style.display = ''; 

        success(function() { // pass down done callback 
         pullToRefresh.style.display = ''; 
         refreshing.style.display = 'none'; 
         content.style.top = '0'; 
         content.addEventListener('transitionEnd', removeTransition); 
        }); 

        refresh = false; 
       } else if(track) { 
        //content.style['-webkit-transition-duration'] = '.25s'; 
        content.style.top = '0'; 
        content.addEventListener('transitionEnd', removeTransition); 

        cancel(); 
       } 
       track = false; 
      }); 

      document.body.addEventListener('touchmove', function(e) { 
       var move_to = contentStartY - (startY - e.changedTouches[0].screenY); 
       if(move_to > 0) track = true; // start tracking if near the top 
       content.style.top = move_to + 'px'; 

       if(move_to > 50) { 
        refresh = true; 
       } else { 
        //content.style['-webkit-transition'] = ''; 
        refresh = false; 
       } 
      }); 
     } 
    }; 
}(); 

谁能请帮助我。

+1

您在parseInt方法中缺少radix参数。 – lifetimes 2013-04-24 09:16:39

+0

@ user125697 radix是可选参数 – 999k 2013-04-24 09:18:38

+0

什么是行号26 – 2013-04-24 09:18:57

回答

5

XPC错误不是来自调用纯JavaScript方法就像parseInt(与基数参数 可选规范,所以所有这些意见是错的很多计数)。


您是missing the third useCapture argument在所有addEventListener电话:

这里:

document.body.addEventListener('touchstart', function(e) { 
    ... 
}, false); //<-- add third argument 

这里:

content.addEventListener('transitionEnd', removeTransition, false); //<-- add third argument 

这里:

document.body.addEventListener('touchend', function(e) { 
    ... 
}, false); //<-- add third argument 

这里:

content.addEventListener('transitionEnd', removeTransition, false); //<-- add third argument 

在这里:

document.body.addEventListener('touchmove', function(e) { 
    ... 
}, false); //<-- add third argument 

注意,在一个newer specification, the argument has been made optional。但那并不重要。

相关问题