289 posts
  • Bought between 100 and 499 items
  • Exclusive Author
  • Sold between 5 000 and 10 000 dollars
  • Has been a member for 5-6 years
  • Referred between 1 and 9 users
dany_j says

Hello! need little help
i need script that detect user device than ridirect to apropriate domain.
example:
if PC than go to www.domain.com
if mobile than go to www.mob.domain.com or www.domain.com/mob
web is html but I asume index need to be php which rederect
i found this one
and if there is some better way please tell me

1152 posts
  • Interviewed on the Envato Notes blog
  • Won a Competition
  • Halloween Competition Winner
  • Exclusive Author
  • Has been a member for 3-4 years
  • Sold between 50 000 and 100 000 dollars
  • Referred between 100 and 199 users
  • Bought between 1 and 9 items
  • United Kingdom
iKreativ says

You can use JS too. Just set the screen width less than or equal to and the redirect location.

<script type="text/javascript">
<!--
if (screen.width <= 320) {
document.location = "mobile.html";
}
//-->
</script>
289 posts
  • Bought between 100 and 499 items
  • Exclusive Author
  • Sold between 5 000 and 10 000 dollars
  • Has been a member for 5-6 years
  • Referred between 1 and 9 users
dany_j says

thanks! this looks realy simple! :)

289 posts
  • Bought between 100 and 499 items
  • Exclusive Author
  • Sold between 5 000 and 10 000 dollars
  • Has been a member for 5-6 years
  • Referred between 1 and 9 users
dany_j says

but seams that is not working if its just that code

254 posts
  • Bought between 1 and 9 items
  • Exclusive Author
  • Has been a member for 3-4 years
  • Referred between 10 and 49 users
  • Sold between 10 000 and 50 000 dollars
PabloFierro says

You can use JS too. Just set the screen width less than or equal to and the redirect location.
<script type="text/javascript">
<!--
if (screen.width <= 320) {
document.location = "mobile.html";
}
//-->
</script>

This is perhaps one of the sloppiest piece of code i’ve seen.

use this instead: http://code.google.com/p/php-mobile-detect/ there’s always a way around this method, but it works perfectly.

1152 posts
  • Interviewed on the Envato Notes blog
  • Won a Competition
  • Halloween Competition Winner
  • Exclusive Author
  • Has been a member for 3-4 years
  • Sold between 50 000 and 100 000 dollars
  • Referred between 100 and 199 users
  • Bought between 1 and 9 items
  • United Kingdom
iKreativ says


You can use JS too. Just set the screen width less than or equal to and the redirect location.
<script type="text/javascript">
<!--
if (screen.width <= 320) {
document.location = "mobile.html";
}
//-->
</script>

This is perhaps one of the sloppiest piece of code i’ve seen.

use this instead: http://code.google.com/p/php-mobile-detect/ there’s always a way around this method, but it works perfectly.

Well go tell Chris Coyier of CSS Tricks, it’s his code. I use my own PHP script.

289 posts
  • Bought between 100 and 499 items
  • Exclusive Author
  • Sold between 5 000 and 10 000 dollars
  • Has been a member for 5-6 years
  • Referred between 1 and 9 users
dany_j says


You can use JS too. Just set the screen width less than or equal to and the redirect location.
<script type="text/javascript">
<!--
if (screen.width <= 320) {
document.location = "mobile.html";
}
//-->
</script>

This is perhaps one of the sloppiest piece of code i’ve seen.

use this instead: http://code.google.com/p/php-mobile-detect/ there’s always a way around this method, but it works perfectly.

Thanks!
I will test that option to

by
by
by
by
by
by