Reputation: 29
Hi I am trying to redirect my homepage www.eco-fireplaces.co.uk to a different web page when opened with a mobile device such as an Ipad, IPhone, Android etc.. I have managed to acheive this using a neat java script on my homepage (see script below)
<script language=javascript>
if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) ||(navigator.userAgent.match(/iPad/i)) || (navigator.userAgent.match(/Android/i)) || (navigator.userAgent.match(/Blackberry/i)))
{
location.replace("http://www.eco-fireplaces.co.uk/mob.html");
}
</script>
but when the alternative web page is opened it just keeps inifinitely reloading thepage over and over??
I have tried using .htaccess to do this but just kept getting 'The page has too many server redirects' error and couldn't get it to work.
I would appreciate it if someone could have a look at the java script and see if I have done anything wrong.
Thanks Andy
Upvotes: 0
Views: 126
Reputation: 7830
Your script is also in the http://www.eco-fireplaces.co.uk/mob.html
page, so when it is opened in a mobile browser, the redirect is triggered again and again.
Related: As there are increasingly different kinds of devices out there, the simple distinction between "Desktop" and "Mobile" versions does not make so much sense. You might want to get into Responsive Design instead:
Responsive web design (often abbreviated to RWD) is an approach to web design in which a site is crafted to provide an optimal viewing experience—easy reading and navigation with a minimum of resizing, panning, and scrolling—across a wide range of devices (from desktop computer monitors to mobile phones).
Upvotes: 1