Reputation: 45
I'm using html and jquery. In my page I am opening an URL, if that URL is failed to open, 'Problem Load Page' or 'Server not found' error is displaying in webpage. How can I throw an Alert Box instead of showing error message webpage. Thanks in advance.
Upvotes: 0
Views: 371
Reputation: 2027
you can check with ajax if page exists, and then redirect to it.
<a href="/somelink" id="test1">Link1</a> <span id="result1"></span>
$.ajax($("#test1").attr("href"), {
statusCode: {
404: function() {
$("#result1").html("not working");
},
200: function() {
$("#result1").html("working");
}
}
});
Upvotes: 2