Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #23670
| From | Jeff Thies <jeff@thelimit.com> |
|---|---|
| Newsgroups | alt.html, comp.lang.javascript |
| Subject | Mobile Redirect |
| Date | 2014-03-25 13:18 -0400 |
| Organization | albasani.net |
| Message-ID | <lgsdo7$3va$1@news.albasani.net> (permalink) |
Cross-posted to 2 groups.
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
Back to comp.lang.javascript | Previous | Next — Next in thread | Find similar | Unroll thread
Mobile Redirect Jeff Thies <jeff@thelimit.com> - 2014-03-25 13:18 -0400
Re: Mobile Redirect Danny <dann90038@gmail.com> - 2014-03-25 11:32 -0700
Re: Mobile Redirect "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-03-25 19:39 +0100
Re: Mobile Redirect Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-03-25 21:49 +0100
csiph-web