Jump to content

MediaWiki:Common.js: Difference between revisions

From Utpalasia Wiki
test
change to user-agent string detection again
 
Line 3: Line 3:
if(document.URL.search("mobile") == -1)
if(document.URL.search("mobile") == -1)
{
{
   var size = window.getComputedStyle(document.body,':after').getPropertyValue('content');
   var ua = navigator.userAgent;


   if (size.indexOf('smallscreen') != -1)
   if(ua.match(/Android/i))
   {
   {
     /*window.location.replace(document.URL + "?useformat=mobile");*/
     if(ua.match(/Mobile/i))
     /*alert("Small screen detected.");*/
    {
      window.location.replace(document.URL + "?useformat=mobile");
    }
  }
  else if((/webos|iphone|ipod|blackberry|windows phone|bada/i).test(ua))
  {
     window.location.replace(document.URL + "?useformat=mobile");
   }
   }
}
}

Latest revision as of 19:04, 7 April 2013

/* Any JavaScript here will be loaded for all users on every page load. */

if(document.URL.search("mobile") == -1)
{
  var ua = navigator.userAgent;

  if(ua.match(/Android/i))
  {
    if(ua.match(/Mobile/i))
    {
      window.location.replace(document.URL + "?useformat=mobile");
    }
  }
  else if((/webos|iphone|ipod|blackberry|windows phone|bada/i).test(ua))
  {
    window.location.replace(document.URL + "?useformat=mobile");
  }
}