please help redirect

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    please help redirect

    does anyone please have a code that would pick up touch phones if they in use, im building a script and one side of it im doing a touch verson but need to redirect a touch phone to the right side if anyone could help, please do, many thanks.

    $http=$_SERVER['HTTP_USER_AGENT'];
    if((substr($http,0,5)=='Opera' and !strpos($http,'Mini'))
    or substr($http,0,7)=='Mozilla'
    or substr($http,0,6)=='Galaxy'
    or substr($http,0,12)=='AmigaVoyager'
    or substr($http,0,=='CyberDog'
    or substr($http,0,5)=='Dillo'
    or substr($http,0,7)=='HotJava'
    or substr($http,0,15)=='IBM WebExplorer'
    or substr($http,0,4)=='iCab'
    or substr($http,0,10)=='LeechCraft'
    or substr($http,0,5)=='Links'
    or substr($http,0,4)=='Lynx'
    or substr($http,0,11)=='NCSA Mosaic'
    or substr($http,0,7)=='NCSA Mosaic'
    or substr($http,0,6)=='retawq'
    or substr($http,0,6)=='Webkit'
    or substr($http,0,4)=='Uzbl'
    or substr($http,0,3)=='w3m'
    or substr($http,0,12)=='WorldWideweb')
    {
    header("Location: http://$_SERVER[SERVER_NAME]/index.php"); normal web side
    }else{
    header("Location: http://$_SERVER[SERVER_NAME]/touch/index.html"); ///touch side
    }

    this does work but it pick's up phones and pc's

    #2
    Detecting touch screen by php is kind of long winded way of doing it as you would have to get so many browser names >.<
    I would suggest doing it via javascript eg:
    Code:
    <script type="text/javascript">
    
    function is_touch_device() {
     return (('ontouchstart' in window)
          || (navigator.MaxTouchPoints > 0)
          || (navigator.msMaxTouchPoints > 0));
    }
     
    if (is_touch_device()) {
     window.location='http://<?=$_SERVER[SERVER_NAME]?>/touch/index.html';
    }
    if the device has no javascript then it will ignore the code.
    Last edited by something else; 22.05.14, 20:36.

    Comment


    • jsyguy23
      jsyguy23 commented
      Editing a comment
      thanks m8 nice one ;)

    #3
    Originally posted by something else View Post
    Detecting touch screen by php is kind of long winded way of doing it as you would have to get so many browser names >.<
    I would suggest doing it via javascript eg:
    Code:
    <script type="text/javascript">
    
    function is_touch_device() {
    return (('ontouchstart' in window)
    || (navigator.MaxTouchPoints > 0)
    || (navigator.msMaxTouchPoints > 0));
    }
    
    if (is_touch_device()) {
    window.location='http://<?=$_SERVER[SERVER_NAME]?>/touch/index.html';
    }
    if the device has no javascript then it will ignore the code.
    Now This will not work on many phones Specially if you use ucweb browser/operamini/etc etc on yout touch phones except default browsers

    Comment


    • jsyguy23
      jsyguy23 commented
      Editing a comment
      what do you recommend m8 ??

    #4
    Originally posted by giant_hacker View Post

    Now This will not work on many phones Specially if you use ucweb browser/operamini/etc etc on yout touch phones except default browsers
    Its pointless redirecting opera mini and ucweb to a better site - they will get there and still not be able to use most of the stuff you have put time into coding.
    if someone is willing to downgrade there web experience to ucweb or opera mini then give them a downgraded site. No point in trying to give them anything else

    Comment


    • jsyguy23
      jsyguy23 commented
      Editing a comment
      same way i was thinking

    #5
    agree with giant_hacker, what if your browser doesn't support java (old phones) javascript will not do so, I'm thinking of redirecting android phones and IOS =) they are the most touchscreen devices, IOS have a keyword apple or safari in their user-agent while android is too common, you don't need to pick all those browsers, just pick the most common like android and IOS, the above code will do

    compatibility is your site's asset so don't just disregard it =) more compatible browser more users
    Last edited by wapxtech; 29.09.14, 23:20.

    http://wapx.amob.com
    Applications, Games, Wallpapers, Ringtones, Videos, Themes, Screensaver and More!!!

    Comment

    Working...
    X