Fetch DNS error and Error 404 with a chrome extension

Well, i'm currently developping a Google Chrome extension and i need to fetch all the DNS and 404 error to make a redirection. The problem is simply that i really don't see how it's possible...

If it's a domain error i want to fetch the domain name and for a 404 error i want to fetch the name page.

Example :

Bad Domain : => Fetch justforthetest

404 Error : => Fetch professinal

Hope someone could provide me some helps... Thanks in advance !


ANSWERS:


Well, the most I was able to do is to send a new XHR request to this URL and check returned status. For wrong domains status seems to be 0, for 404 pages it is 404.

background.html

chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
    if(changeInfo.status == "loading") {
        var xhr = new XMLHttpRequest();
        xhr.open("GET", tab.url, true);
        xhr.onreadystatechange = function() {
            if (xhr.readyState == 4) {
                if(xhr.status == 0) {
                    console.log("wrong domain:", tab.url);
                } else if(xhr.status == 404) {
                    console.log("404 page:", tab.url);
                } else if(xhr.status == 200) {
                    console.log("regular page:", tab.url);
                }
            }
        }
        xhr.send();
    }
}); 


 MORE:


 ? chrome.management.onEnabled Not Firing
 ? Position:Absolute withing Position:Relative in Chrome
 ? How to get the windows user name using javascript in google chrome browser for google chrome extension
 ? Call function when sound has ended
 ? Bookmarklet to open a new window forwards current window to [Object Window]?
 ? How to call run/invoke a local application inside google chrome
 ? Google Chrome Won't Accept .contentDocument or .contentWindow!
 ? Issue with background color and Google Chrome
 ? Issue with background color and Google Chrome
 ? Issue with background color and Google Chrome