Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript error uncaught exception

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.

like image 955
Amar Banerjee Avatar asked Apr 24 '13 09:04

Amar Banerjee


People also ask

What is uncaught exception in JavaScript?

According to the Mozilla website for developer documents, “the TypeError object represents an error when a value is not of the expected type.” Uncaught means that the error was not caught in the catch part of the try-catch block.

What is an uncaught exception error?

June 01, 2022. CWE 248-Uncaught Exception occurs when an exception is not caught by a programming construct or by the programmer, it results in an uncaught exception. In Java, for example, this would be an unhandled exception that would terminate the program.


1 Answers

XPC errors don't come from calling a pure Javascript method like parseInt (and the radix argument is optional by specification, so all those comments 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.

like image 89
Esailija Avatar answered Sep 20 '22 11:09

Esailija