mardi 25 mars 2014

Mobile Redirect topic




I have a client with a site that has a mobile subdomain.

There are a number of ways to redirect and an unholy number of devices.

What I thought was to through up a large mobile type link once. There is
a mobile link in a normal font elsewhere.

So:

function runSwitchLink(){
if(window.screen.width < 800){
if(!document.getCookie('asked')){
document.write('<a href="javascript:location.href=' +
"'http://mobile.some-site.com/mobile_redirect.php'" + '"
class="asked">Switch to Mobile Site</a>');

document.cookie = 'asked=yes;path=/';
}
}
}

runSwitchLink();

// document.getCookie defined elsewhere

Site requires cookies (cart), so cookies off is not an issue.

I think screen.width takes into account dppx oversampling, and I think
it is available always, even before page load. Is this right?

Other ideas?

Jeff





Aucun commentaire:

Enregistrer un commentaire