function log( msg ) { $('#result').append( msg + '<br/>'); }

try {
    log("href with attr: " + $(window).attr('location').href);
} catch (e) {
    log("error on attr: " + e.message);
}

// Instead
log("href with prop: " + $(window).prop('location').href);