WebSite X5Help Center

 
William T.
William T.
User

Detect if mobile device and send to different ulr  en

Autor: William T.
Visitado 1044, Seguidores 1, Compartilhado 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

http://photoapps.tuckpixs.com/portraitphotos/tuckpixs

Publicado em
3 RESPOSTAS - 1 CORRIGIR
Anthony A.
Anthony A.
User

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

Ler mais
Publicado em de Anthony A.
William T.
William T.
User
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>

Ler mais
Publicado em de William T.
William T.
William T.
User
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>

Ler mais
Publicado em de William T.