2

It behaves inconsistent with respect to browsers.

Google Chrome: Can invoke first one but cannot invoke another one.

$(function () {
    $("div[href]").click(function (event) {
        debugger;

        window.protocolCheck("abcd:",
        function () {
            console.log('err1')
        }, function () {
            console.log('succ1');
            window.protocolCheck("xyz:",
                function () {
                    console.log('err2');
                }, function () {
                    console.log('succ2');
                });
        });



    });
});
<!DOCTYPE html>
<html>

<head lang="en">
    <meta charset="UTF-8">
    <title>Custom Protocol Detection</title>
</head>

<body id="abcd">
    <h1>Click one of these labels:</h1>
    <a href="#" id="atemp"></a>
    <div href="blahblah:randomstuff"  style="background-color:aquamarine">
        Non-exist protocol
    </div>
    <div href="mailto:johndoe@somewhere.com" style="background-color:aqua">
        Send email
    </div>
    <script src="https://code.jquery.com/jquery-1.11.2.min.js"></script>
   <script src="https://github.com/ismailhabib/custom-protocol-detection/blob/master/protocolcheck.js"></script>
    <script src="example.js"></script>
</body>

</html>
  1. I want to validate in user registry that some protocol exist.

  2. If registry not found we download it if found we invoke next protocol.

  3. Library https://github.com/ismailhabib/custom-protocol-detection/blob/master/protocolcheck.js

And for invoking can we use protocol check library.

1 Answers1

0

The second callback is called on success. So, the first check fails, then the second check code will not be invoked.