2013-07-20 18:19:58 +02:00
|
|
|
(function($) {
|
2014-01-14 00:32:09 +01:00
|
|
|
$.fn.custom404 = function(options) {
|
|
|
|
var defaults = {
|
|
|
|
404: "/404.html",
|
|
|
|
403: "/403.html",
|
|
|
|
500: "/505.html"
|
|
|
|
};
|
|
|
|
if (options) $.extend(defaults, options);
|
|
|
|
if (!this.selector) var selected = "a";
|
|
|
|
else var selected = this.selector;
|
|
|
|
$(selected).click(function() {
|
|
|
|
event.preventDefault();
|
|
|
|
var address = $(this).attr("href");
|
2013-07-20 18:19:58 +02:00
|
|
|
$.ajax({
|
2014-01-14 00:32:09 +01:00
|
|
|
url: address,
|
|
|
|
success: function() {
|
|
|
|
window.location.href = address;
|
|
|
|
},
|
|
|
|
error: function(xhr) {
|
|
|
|
window.location.href = defaults[xhr.status];
|
2013-07-20 18:19:58 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2014-01-14 00:32:09 +01:00
|
|
|
};
|
|
|
|
})(jQuery);
|