JS Redirection – IOS – Android
Create in the same folder:
– mobile-detector.html
It this the javascript that detects the device type
– ios.html
The page for IOS devices
– android.html
The page for Android devices
– error.html
An Error page
mobile-detector.html
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | <!DOCTYPE html> <html> <head> <script type= "text/javascript" > // ####################################################### // Mobile JS Redirect // Don't Break My b***s - Gimme Code! Project // Author: Andrea Tonin - http://blog.lucedigitale.com // This code come with absolutely no warranty // If you use this code in your project please give a link to http://blog.lucedigitale.com // Thanks in advance // ####################################################### var isMobile = { Android: function () { return navigator.userAgent.match(/Android/i); }, BlackBerry: function () { return navigator.userAgent.match(/BlackBerry/i); }, iOS: function () { return navigator.userAgent.match(/iPhone|iPad|iPod/i); }, Opera: function () { return navigator.userAgent.match(/Opera Mini/i); }, Windows: function () { return navigator.userAgent.match(/IEMobile/i); }, any: function () { return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows()); } }; if ( isMobile.Android() ) { document.location.href = "android.html" ; } else if (isMobile.iOS()) { document.location.href= "ios.html" ; } else { document.location.href= "error.html" ; } </script> </head> <body> <center> <br> <b><h1>You are being redirected to other site.</h1> <br> <br> <h1>If you are not redirected within 4 seconds</h1></b> <br> <h1><a href= "android.html" >ANDROID HERE</h1></a> <h1><a href= "ios.html" >IOS HERE</h1></a> </center> </body> </html> |
ios.html
1 2 3 4 5 6 7 8 9 10 11 12 | <! DOCTYPE html> < html > < head > </ head > < body > <!-- Questo è un commento, non viene renderizzato dal browser --> < h1 >IOS!</ h1 > </ body > </ html > |
android.html
1 2 3 4 5 6 7 8 9 10 11 12 | <! DOCTYPE html> < html > < head > </ head > < body > <!-- Questo è un commento, non viene renderizzato dal browser --> < h1 >Android!</ h1 > </ body > </ html > |
error.html
1 2 3 4 5 6 7 8 9 10 11 12 | <! DOCTYPE html> < html > < head > </ head > < body > <!-- Questo è un commento, non viene renderizzato dal browser --> You need an Android or IOS device! </ body > </ html > |