I advertise a company, basicaly I\'m an affiliate. I want to redirect my mobile viewers to the mobile version of my affiliate website. I\'m thinking of doing this with scree
It's generally much safer to check the browser's user-agent, as then you will know whether they are on an Android, iPhone, iPad, iPod, Nokia, ..., and you are given greater flexibility to direct the user from there. I use the following Javascript (probably borrowed from another source):
var isMobile = function() {
console.log("Navigator: " + navigator.userAgent);
return /(iphone|ipod|ipad|android|blackberry|windows ce|palm|symbian)/i.test(navigator.userAgent);
};
Screen width is an available technique. I usually see this used with CSS Media Queries, changing the content based on "device-width" and "device-height". E.g.
@media only screen and (max-device-width: 480px) {
/* For small devices, just CSS */
}
To go with the technique of screen width / height, this is from Mozilla docs:
// crude way to check that the screen is at 1024x768
if (window.screen.width < 1000) {
// resolution is below 10 x 7
window.location = 'm.mysite.com'; //for example
}
Here is an in-depth list of mobile screen resolutions.
A few caveats:
As mobile devices get better at rendering and interaction, be aware that oftentimes users may prefer to see the original site instead of the mobile site, full stop. Try to provide a method back to the main site.
Hope this all helps you suss out your solution!