$(function () {
$("div[href]").click(function (event) {
debugger;
//for validation purpose.
window.location = "abcd:";
//if it is validated then
window.location ="xyz:";
});
});Run Code Online (Sandbox Code Playgroud)
<!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="example.js"></script>
</body>
</html>Run Code Online (Sandbox Code Playgroud)