Код: Выделить всё
function checkReadyState() {
if (reader.readyState === 4) {
//check to see whether request for the file failed or succeeded
if ((reader.status == 200) || (reader.status == 0)) {
//page exists -- redirect to the url
console.log(mobile+ " : does exist") ;
document.location.href = mobile ;
} else {
//if the url does not exist
console.log(mobile+ " : does NOT exist") ;
goToStore() ;
}
}
}// end of checkReadyState()
console.log("Redirect to App or to Store") ;
var mobile = "myapp://path/to/resource" ;
var reader = new XMLHttpRequest();
reader.open('get', mobile, true);
//check each time the ready state changes
//to see if the object is ready
reader.onreadystatechange = checkReadyState;
// Sends the request for the file data to the server
// Use null for "get" mode
reader.send(null);
Подробнее здесь: https://stackoverflow.com/questions/795 ... l-is-valid
Мобильная версия