0

I am trying to redirect to my mobile website. This is the code I a am using in the head code of my homepage (index.html). This supposed to automatically redirect mobile devices to my mobile website, but it doesn't work.

<script>
if (document.location.search.indexOf("skipmobile") >= 0) {
document.cookie = "skipmobile=1";
}
else if ((document.location.hostname.match(/\.mobi$/) || screen.width < 699)
&& document.cookie.indexOf("skipmobile") == -1)
{
document.location = "mobile/";
}
</script>

Can somebody please give me some ideas about possible mistakes or improvements?

This is my website: www.accurateprinting.com

  • 1
    I think you mean [`window.location` instead of `document.location`](http://stackoverflow.com/questions/7857878/window-location-vs-document-location), although some browsers recognize both. – Blazemonger Oct 10 '13 at 16:04
  • I just tried that, but it didn't work Blazemonger. This is crazy! – Enrique Hidalgo Oct 10 '13 at 19:09

0 Answers0