Récupérer le code source d'une page html en javascript

Un collègue m'a posé une question ce matin au boulot : comment récupérer le code source d'une page HTML en javascript ? Cerise sur le gâteau : cela doit fonctionner sous IE 6...

J'ai pondu une truc vite-fait ; rien de révolutionnaire ; il y a sans doute d'autres moyens de faire...

var

/**
 *  @return {mixed} XMLhttpRequest instance or ActiveXObject for IE < 9.
 *  @throws {Error} If web browser doesn't support async requests.
 */
Xhr = window.ActiveXObject ? function () {
    var names = ['Msxml2.XMLHTTP.6.0', 'Msxml2.XMLHTTP.3.0',
            'Msxml2.XMLHTTP', 'Microsoft.XMLHTTP'],
        i, n = names.length;
    for (i = 0; i < n; i++) {
        try { return new ActiveXObject(names[i]); }
        catch (e) { }
    }
} : window.XMLHttpRequest ? function () {
    return new XMLHttpRequest();
} : function () {
    throw new Error('Web browser doesn\'t support async requests.');
},

/**
 *  Get HTML code source of a web page.
 *
 *  @example
 *      getSource('my_page.html', function (source) {
 *          // do someting with source
 *      }, function () {
 *          // do something on error
 *      });
 *
 *  @param {String} url Url of the web page. **page must have the same
 *  web host as the current page** (no cross-site request).
 *  @param {Function} callback Callback function called when web page
 *  source is ready. Receive one parameter : the html code of the requested 
 *  page as a string.
 *  @param {Function} [error] Callback function called when an error occured.
 *  @throws Error If web browser doesn't support async requests.
 */
getSource = function (url, callback, error)
{
    if (!callback) {
        throw new Error('callback function needed');
    }
    error = error || function () { };
    
    // Create async request
    var req = new Xhr();
    // Listen to response
    req.onreadystatechange = function () {
        if (req.readyState === 4) {
            if ( req.status === undefined || req.status === 0 ||
                    (req.status >= 200 && req.status < 300) ||
                    req.status === 304 ) {
                // OK
                callback(req.responseText);
            } else {
                // KO
                error();
            }
            // Fix memory leaks for IE
            req.onreadystatechange = new Function();
        }
    };
    // Open and send
    req.open('GET', url, true);
    req.send();
};
Récupérer le code HTML d'une page web.