Detect if mobile device and send to different ulr
Autor: William T.
Visited 1042,
Followers 1,
Udostępniony 0
I wish to have my web5x site detect if the user is on a mobile device or not and if they are on a mobile device, send them to a different site. Can you tell me where and what code to put in do make this happend?
My "regular" site is www.tuckpixs.com
the site I want mobile devices to go to is
Posted on the
you can put this java code inside the head section of your website
<script type="text/javascript"> <!-- if (screen.width <= 800) { [removed] = "http://m.domain.com"; } //--> </script>
or you can use .htaccess and put this code inside it
RewriteEngine On
# Check for mime types commonly accepted by mobile devices RewriteCond %{HTTP_ACCEPT} "text\/vnd\.wap\.wml|application\/vnd\.wap\.xhtml\+xml" [NC] RewriteCond %{REQUEST_URI} ^/$ RewriteRule ^ http://m.domain.com%{REQUEST_URI} [R,L]
REMEMBER to change m.domain.com to reflect your address.
if this post is the correct answer, please mark this answer as correct answer.
------------------------------------------------------------
Good Luck
http://www.usx5host.com (6 months free Web Host for x5 users, promo code: usx56m)
http://www.usx5.com (Templates and support for x5)
http://www.wdesigners.us
Autor
I tried this exact code by both adding html to the head section and by putting just this code in the .access in the /public_html folder. It does not work. Can you see anything that is wrong?
<script type="text/javascript"> <!-- if (screen.width <= 800) { [removed] = "http://photoapps.tuckpixs.com/portraitphotos/tuckpixs"; } //--> </script>
Autor
Nevermind.. this is the code that actually worked putting it in the header:
<script>if (screen.width < 800){[removed].assign("http://photoapps.tuckpixs.com/portraitphotos/tuckpixs");}</script>