Alert and redirect mobile devices
by
27 Dec 2010
You can make your forum produce an unobtrusive javascript alert whenever your community members view your site from a mobile device, such as an Apple iPhone/iPod, Android-based device or Symbian-based device by entering a little javascript in your forum's header or footer template. Code:
function detectMobilePlatform() { if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) { if (confirm("The message you want them to see.")) { document.cookie = "mobile_redirect=false"; window.location = "http://link/to/page"; } else { setNoRedirect(); } } else if(navigator.userAgent.match(/android/i)) { if (confirm("The message you want them to see.")) { document.cookie = "mobile_redirect=false"; window.location = "http://link/to/page"; } else { setNoRedirect(); } } else if((navigator.userAgent.match(/Symbian/i)) || (navigator.userAgent.match(/Nokia/i))) { if (confirm("The message you want them to see.")) { document.cookie = "mobile_redirect=false"; window.location = "http://link/to/page"; } } function setNoRedirect() { var date = new Date(); var days = 30; date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+ date.toGMTString(); document.cookie = "mobile_redirect=false" + expires; } detectMobilePlatform() Replace the message with whatever message you want your forum members to see, and replace the URL to the resource you want them to see when they click ok on the mobile device. |
Similar Mods
Forum Style Lightweight Style for Small Screen Devices (cell phone, iphone, mobile, android) | vBulletin 4.x Styles |