Advertisement
Guest User

Untitled

a guest
Apr 27th, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script>
  2. function checkcode(url){
  3.         var xhr = new XMLHttpRequest();
  4.         xhr.open('GET', url, false);
  5.         try{xhr.send();return xhr.status()}
  6.         catch{return null;}
  7. function gproto(url){
  8.         if (checkcode("https://"+a) == 200)){window.location.href = "https://"+a;}
  9.         else if (checkcode("http://"+a == 200)){window.location.href = "http://"+a;}
  10.         else {window.location.href = "https://"+a;}//Могут быть иной возврат, 400, 403, возвращаем стандартный протокол
  11.  
  12. function Reloc(a)
  13. {
  14.     if (a.substr(0,6) != "http://" || a.substr(0,6) != "https://"){gproto(a);}
  15.     else {window.location.href = a;}
  16. }
  17. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement