LEFT | RIGHT |
1 function download(url) { | 1 function download(url) { |
2 if(url.indexOf("http") == 0) { //Only accepts http and https URLs | 2 if(url.indexOf("http") == 0) { //Only accepts http and https URLs |
3 try { | 3 try { |
4 var request = new window.XMLHttpRequest(); | 4 var request = new window.XMLHttpRequest(); |
5 request.open('GET', url, false); | 5 request.open('GET', url, false); |
| 6 if(opera.version() >= 12.1) |
| 7 request.timeout(12000); //Only supported in Oper
a 12.1+, 12 seconds timeout |
6 request.send(); | 8 request.send(); |
7 if (request.readyState == 4 && request.status == 200) { | 9 if (request.readyState == 4 && request.status == 200) { |
8 return request.responseText; | 10 return request.responseText; |
9 } | 11 } |
10 } | 12 } |
11 catch(e) {} | 13 catch(e) {} |
12 } | 14 } |
13 return false; | 15 return false; |
14 } | 16 } |
LEFT | RIGHT |