The Arcive of vBulletin Modifications Site. |
|
|
Alert and redirect mobile devices
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. |
|
#2
|
||||
|
||||
|
awesome
it will help in my site becuse its for mobile stuf and most users are visiting it from mobile http://www.7elm3aber.com/vb |
![]() |
|
|