Difference between revisions of "MediaWiki:Common.js"
		
		
		
		
		
		
		Jump to navigation
		Jump to search
		
				
		
		
		
		
		
		
		
		
	
| m (removed alert box) |  (change to user-agent string detection again) | ||
| (18 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
| /* Any JavaScript here will be loaded for all users on every page load. */ | /* Any JavaScript here will be loaded for all users on every page load. */ | ||
| − | if( | + | if(document.URL.search("mobile") == -1) | 
| { | { | ||
| − |    window.location.replace(document.URL + "?useformat=mobile"); | + |    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"); | ||
| + |   } | ||
| } | } | ||
Latest revision as of 20: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");
  }
}

