Skip to content

Instantly share code, notes, and snippets.

@makbeta
Created June 13, 2013 19:00
Show Gist options
  • Save makbeta/5776391 to your computer and use it in GitHub Desktop.
Save makbeta/5776391 to your computer and use it in GitHub Desktop.
JS for Luminate CMS: redirect users to a different page if they are viewing it in mobile browser
var currentPath = '${path}';
var redirects = [{ "from":"/give-now","to":"http://localhost"},
{"from":"/z-test/responsive-donation-redirect.html","to":"http://localhost"}];
$.getJSON( "/components/mobile/check-setting.jsp", function(data) {
if(data.isMobileDevice) {
if(redirects.length > 0) {
for(i=0; i<redirects.length; i++) {
if(redirects[i].from == currentPath) {
console.log('DNL: We are on a mobile device, redirecting to '+redirects[i].to);
window.location = redirects[i].to;
}
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment