最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

jquery - Javascript error uncaught exception - Stack Overflow

programmeradmin0浏览0评论

I am using a javascript file called pull.js. It is using for pulldown refresh in Ipad but , when I use that other jquery and javascript stop working? It is giving the following uncaught exception error :

" 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] "

I am passing the content of this js file :

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;
                }
            });
        }
    };
}();

Can anyone please help me.

I am using a javascript file called pull.js. It is using for pulldown refresh in Ipad but , when I use that other jquery and javascript stop working? It is giving the following uncaught exception error :

" 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] "

I am passing the content of this js file :

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;
                }
            });
        }
    };
}();

Can anyone please help me.

Share Improve this question edited Jun 17, 2013 at 11:26 PP. 10.9k7 gold badges47 silver badges59 bronze badges asked Apr 24, 2013 at 9:14 Amar BanerjeeAmar Banerjee 5,0125 gold badges36 silver badges52 bronze badges 9
  • 1 You are missing the radix parameter on your parseInt method. – dsgriffin Commented Apr 24, 2013 at 9:16
  • @user125697 radix is optional paramneter – 999k Commented Apr 24, 2013 at 9:18
  • what is line number 26 – Arun P Johny Commented Apr 24, 2013 at 9:18
  • @555k That is where the error is ing from, when you fix that it works. – dsgriffin Commented Apr 24, 2013 at 9:20
  • Handle your error thru try{ }catch(e){ } – Madhu Commented Apr 24, 2013 at 12:00
 |  Show 4 more ments

1 Answer 1

Reset to default 5 +100

XPC errors don't e from calling a pure Javascript method like parseInt (and the radix argument is optional by specification, so all those ments are wrong on many counts).


You are missing the third useCapture argument on all your addEventListener calls:

Here:

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

Here:

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

Here:

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

Here:

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

And here:

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

Note that in a newer specification, the argument has been made optional. But that doesn't really matter.

发布评论

评论列表(0)

  1. 暂无评论