I am trying to detect XHR mismatch on mixed content. It seems that different browsers have different implementations:
var xhr = new XMLHttpRequest();
try {
xhr.open('http://otherdomain/');
} catch (err) {
console.log(err);
}
try {
xhr.send();
} catch (err) {
console.log(err);
}
I do not want to use autodetection ( xhr.open('//otherdomain')), since the target may not support http or https. I just want to know that the call failed, so I can show an error on my page. Is it possible to handle this correctly for all browsers?
source
share