Catching an exception on Send. This happens when request for HEAD returns 405 Method Not Allowed. Instead of error http status, this may throw an exception. Return false and fallback to link download.
This commit is contained in:
committed by
Jimmy Wärting
parent
3caf053bbd
commit
9bd5261f60
+5
-1
@@ -49,7 +49,11 @@ function corsEnabled (url) {
|
||||
var xhr = new XMLHttpRequest()
|
||||
// use sync to avoid popup blocker
|
||||
xhr.open('HEAD', url, false)
|
||||
xhr.send()
|
||||
try {
|
||||
xhr.send();
|
||||
}catch(e) {
|
||||
return false;
|
||||
}
|
||||
return xhr.status >= 200 && xhr.status <= 299
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user