How to direct a mobile user to the mobile site and not the full blown site.

How to direct a mobile user to the mobile site and not the full blown site.

I am a total newbie here. I have been writing websites for myself and friends for a number of years, more as a hobby and for no reward.


I did a site for a friend who was approached by a company saying that his website was not mobile friendly, and they were correct. For £200 they developed a mobile friendly site probably using jQuery, and it is fine.

In order for the mobile site to be seen on a mobile device the mobile design company sent him some code which I inserted in the 'head' of his 'index' page.

Everything works fine, this is the code;


1. Place the following code ABOVE the </head> tag

=================================================================

<script type="text/javascript">

if(window.location.hash != '#mobile=off') {

if (screen.width <= 1023) {

document.location = http://mobilefromweb.co.uk/sites/XXXXXX;

}

}

</script>

=================================================================

2. Place the following code ABOVE the </body> tag

=================================================================

<script type="text/javascript">

if(window.location.hash == '#mobile=off') {

var a = document.getElementsByTagName('a'), href;

for(var i = 0; i < a.length; i++) {

href = a[i].href.toLowerCase();

if((href.indexOf("http://") == -1 && href.indexOf("https://") == -1) ||

(window.location.hostname && href.indexOf(window.location.hostname) != -1)) {

a[i].href = href + '#mobile=off'

}

}

}

</script>


but what do I need to do in my site for the same thing to happen?

If my site was say 1234joe.co.uk and within that site I had a folder 'mobile' with all my 'mobile' files in it.


How do I tell the mobile browser to look at my mobile files and not my main site?

Thanks

Alan