289 posts
  • Has referred 1+ members
  • Has sold $5,000+ on Envato Market
  • Has collected 100+ items on Envato Market
  • Had an item featured on Envato Market
+2 more
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

1289 posts LoveThemes
  • Has referred 100+ members
  • Has sold $75,000+ on Envato Market and is now an Elite Author
  • Has collected 1+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+6 more
LoveThemes 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
  • Has referred 1+ members
  • Has sold $5,000+ on Envato Market
  • Has collected 100+ items on Envato Market
  • Had an item featured on Envato Market
+2 more
dany_j says

thanks! this looks realy simple! :)

289 posts
  • Has referred 1+ members
  • Has sold $5,000+ on Envato Market
  • Has collected 100+ items on Envato Market
  • Had an item featured on Envato Market
+2 more
dany_j says

but seams that is not working if its just that code

254 posts
  • Has been part of the Envato Community for over 3 years
  • Has referred 10+ members
  • Has sold $40,000+ on Envato Market
  • Has collected 1+ items on Envato Market
+3 more
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.

1289 posts LoveThemes
  • Has referred 100+ members
  • Has sold $75,000+ on Envato Market and is now an Elite Author
  • Has collected 1+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+6 more
LoveThemes 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
  • Has referred 1+ members
  • Has sold $5,000+ on Envato Market
  • Has collected 100+ items on Envato Market
  • Had an item featured on Envato Market
+2 more
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