Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 1st, 2012  |  syntax: JavaScript  |  size: 2.13 KB  |  hits: 31  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <script type="text/javascript">
  2.             <!--
  3.             Idk how to get cookies
  4.             and have value=Y run
  5.             function prevY() and if
  6.             value=N , to do nothing
  7.             -->
  8.            
  9.             function fmobic();
  10.                     var iMb = {
  11.             Android: function() {
  12.                 return navigator.userAgent.match(/Android/i) ? true : false;
  13.             },
  14.             BlackBerry: function() {
  15.                 return navigator.userAgent.match(/BlackBerry/i) ? true : false;
  16.             },
  17.             iOS: function() {
  18.                 return navigator.userAgent.match(/iPhone|iPad|iPod/i) ? true : false;
  19.             },
  20.             Windows: function() {
  21.                 return navigator.userAgent.match(/IEMobile/i) ? true : false;
  22.             },
  23.             any: function() {
  24.                 return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Windows());
  25.             }
  26.         };
  27.         if (iMB == true)
  28.             {
  29.                 mobiRED();
  30.               } else {
  31.                 alert("x is not 4");
  32.               }else{
  33.    // do nothing
  34.                 }
  35.                 function mobiRED() {}
  36.                        var x;
  37.                         var r=confirm("Mobile device detected, redirect to mobile version?");
  38.                         if (r==true)
  39.                           {
  40.                               mocosetY()
  41.                           }
  42.                         else
  43.                           {
  44.                               mocosetN()
  45.                       }
  46.                       }
  47.                       function mocosetY(); {
  48.                           document.cookie = "moco=Y"; expires=Fri, 1 Jan 2016 12:10:10 UTC; path=/'
  49.                          window.location = "/mobile"
  50.                      }
  51.                      function mocosetN(); {
  52.                          document.cookie = "moco=N";
  53.                      }
  54.                      function prevY(); {
  55.                          window.location = "/mobile"
  56.                      }
  57.                          window.onload = mobiRED;
  58.  
  59.            </script>