Difference between revisions of "MediaWiki:Common.js"
Jump to navigation
Jump to search
(mobile redirect using detectmobilebrowsers.com method) |
(removed detectmobilebrowser code (couldn't get regular page, even on desktop (had to disable JS)), switched to simplistic UA sniffing) |
||
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. */ | ||
− | var | + | if(document.URL.search("mobile") == -1) |
+ | { | ||
+ | var ua = navigator.userAgent; | ||
+ | if( navigator.userAgent.match(/Android/i) | ||
+ | || navigator.userAgent.match(/webOS/i) | ||
+ | || navigator.userAgent.match(/iPhone/i) | ||
+ | || navigator.userAgent.match(/iPod/i) | ||
+ | || navigator.userAgent.match(/BlackBerry/i) | ||
+ | || navigator.userAgent.match(/Windows Phone/i)) | ||
{ | { | ||
− | + | window.location.replace(document.URL + "?useformat=mobile"); | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
} | } | ||
− | |||
− | |||
− | |||
− | |||
} | } |
Revision as of 15:25, 6 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( navigator.userAgent.match(/Android/i) || navigator.userAgent.match(/webOS/i) || navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPod/i) || navigator.userAgent.match(/BlackBerry/i) || navigator.userAgent.match(/Windows Phone/i)) { window.location.replace(document.URL + "?useformat=mobile"); } }