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

1724 posts LoveThemes
  • Nominated Community Superstar of the month
  • Contributed a blog post
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $75,000+ on Envato Market and is now an Elite Author
+8 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 4 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.

1724 posts LoveThemes
  • Nominated Community Superstar of the month
  • Contributed a blog post
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $75,000+ on Envato Market and is now an Elite Author
+8 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

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by