-4

Have defined:

var ru_cryptopro_npcades_10_native_bridge = {

    callbacksCount : 1,
    callbacks : {},

    resultForCallback : function resultForCallback(callbackId, resultArray) {

        var callback = ru_cryptopro_npcades_10_native_bridge.callbacks[callbackId];

        if (!callback) return;

        callback.apply(null, resultArray);

    },

    call : function call(functionName, args, callback) {

        var hasCallback = callback && typeof callback == "function";
        var callbackId = hasCallback ? ru_cryptopro_npcades_10_native_bridge.callbacksCount++ : 0;

        if (hasCallback) ru_cryptopro_npcades_10_native_bridge.callbacks[callbackId] = callback;

        var iframe = document.createElement("IFRAME");
        var arrObjs = new Array("_CPNP_handle");

        try {

            iframe.setAttribute("src", "cpnp-js-call:" + functionName + ":" + callbackId+ ":" + encodeURIComponent(JSON.stringify(args, arrObjs)));

        }
        catch(e) {

            alert(e);

        }

        document.documentElement.appendChild(iframe);
        iframe.parentNode.removeChild(iframe);
        iframe = null;

    },

};

Have got such warning: Warning 1 Expected identifier or string C:\Users\Administrator\documents\visual studio 2010\Projects\WebAppSelf3\WebAppSelf3\js\CadesLoad.js 453 1 WebAppSelf3

Why?

Secret
  • 2,627
  • 7
  • 32
  • 46

3 Answers3

2

The error is referring to your hanging , comma after the big call: function .....{} block. It's malformed object.

Amy
  • 7,388
  • 2
  • 20
  • 31
2

Chrome parses that just fine, but I have a hunch whatever environment you have that is throwing this error doesn't like that trailing comma in your object literal.

    },

};

Which may need to be:

    }

};

Which again, is wierd, because this seem to work in at least some browsers: http://jsfiddle.net/Aa6yc/1/

Though it's definately not good form.

Alex Wayne
  • 178,991
  • 47
  • 309
  • 337
1

The cause of this types of errors can often be a misplaced comma in a object or array definition:

var obj = {
   id: 23,
   name: "test",  <--
}

Reference: Possible cases for Javascript error: "Expected identifier, string or number"

Community
  • 1
  • 1
Secret
  • 2,627
  • 7
  • 32
  • 46