Working in HTML/SCSS/JQUERY.
Want to link to a webpage but if it's a broken link that it will load the saved .mht
version.
Working in HTML/SCSS/JQUERY.
Want to link to a webpage but if it's a broken link that it will load the saved .mht
version.
Another user provided this code in other thread of this forum to chek if a link is broken (JavaScript/jQuery check broken links)
function urlExists(url, callback) {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState === 4) {
callback(xhr.status < 400);
}
};
xhr.open('HEAD', url);
xhr.send();
}
urlExists(someUrl, function(exists) {
console.log('"%s" exists?', someUrl, exists);