I'm includding a little javascript that I wrote for our website and looking for some feedback on it. What I find interesting is that when I visit it from google on an ipad it continues on to the main site without redirecting, but when I type in the address manually, it works just fine. Any thoughts.
<script type="text/javascript"> <!CDATA[
var mobile = (/iphone|ipad|ipod/android/blackberry/mini/windows\sce|palm/i.test(navigator.userAgent.toLowerCase()));
var from (/m.example.com|http://www.exampe.com/i.test(document.referrer.toLowerCase()));
if (from) {}
else {
if (mobile) {document.location = "http://m.example.com";}
}
//]></script>
<script type="text/javascript"> <!CDATA[
var mobile = (/iphone|ipad|ipod/android/blackberry/mini/windows\sce|palm/i.test(navigator.userAgent.toLowerCase()));
var from (/m.example.com|http://www.exampe.com/i.test(document.referrer.toLowerCase()));
if (from) {}
else {
if (mobile) {document.location = "http://m.example.com";}
}
//]></script>