#1
  1. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Mar 2008
    Posts
    659
    Rep Power
    38

    Iphone sniffer is not working


    Hi, I found some PHP sniffer code for the iphone, but it is not working. Here is the code I have in the header:

    Code:
    <? if(strstr($_SERVER['HTTP_USER_AGENT'],'iPhone') || strstr($_SERVER['HTTP_USER_AGENT'],'iPod'))
    {
      header('Location: http://www.mysite.com/md/iphone.htm');
      exit();
    }
    
    ?>
    My iphone just stays on www.mysite.com and does not redirect to the iphone.htm.

    What am I doing wrong?

    thanks
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Mar 2008
    Posts
    659
    Rep Power
    38

    I also tried JavaScript


    I also tried using JavaScript right above the <body> tag

    Here's my code:
    Code:
    <script language=”javascript”>
    if (navigator.userAgent && ( navigator.userAgent.indexOf(“iPad”) > -1 || navigator.userAgent.indexOf(“iPhone”) > -1 ))
    {
    window.location.replace("http://www.mysite.com/md/iphone.htm");
    }
    </script>
    But the site does not go to the new location.
    What am I doing wrong?
    thanks
    -
    Last edited by lelales; February 7th, 2011 at 07:10 AM.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Mar 2008
    Posts
    659
    Rep Power
    38

    Figured it out


    Hey, I had curly quotes in my code, because I copied and pasted from the internet. Once I changed it to straight quotes, it worked.

    thanks
    -

IMN logo majestic logo threadwatch logo seochat tools logo