Cross browser JavaScript implementation of xhr
Unfortunately, there is a new API for AJAX called fetch. It even has a polyfill. It even has a polyfill for older browsers which looks to me like its already doing what you aim to do.

But anyways, onto your code.

I see you have a long list of ternaries to set values or a default to the options. Instead of that, create an object hosting your defaults, and use Object.assign to merge it and the user config into an object. This throws away the need for doing a ternary/if-else on your code by providing sensible defaults.

var defaults = {
  method: 'GET',
  url: window.location.href,
  username: undefined,
  password: undefined,
  withCredentials: undefined
};

var mergedOptions = Object.assign({}, defaults, options);

var _xhr = new window.XMLHttpRequest();

_xhr.open(mergedOptions.method, mergedOptions.url, true, mergedOptions.username, mergedOptions.password);

_xhr.withCredentials = mergedOptions.withCredentials


For calling the callbacks, consider using call with a context of null. This way, the callback has no assumptions on what the context is and code doesn't accidentally bind something to the global scope.

Alternatively, consider returning a Promise from your function. This way, it acts more like jQuery and the standard fetch.

function xhr(options){
  return new Promise(function(resolve, reject){
    // setup XHR

    if (this.status &gt;= 200 &amp;&amp; this.status &lt; 400) resolve(this.responseText, this.status, responseHeaders, this);
    else reject(this, this.status, responseHeaders);

    // send XHR
  });
}

xhr({...}).then(onSuccess, onError);