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

    Join Date
    Mar 2008
    Posts
    643
    Rep Power
    38

    Ipad and iphone sniffer


    Hello,
    I need to check if the viewer is using an ipad or iphone, and if so, include a new css file.
    Can anyone help with this?
    thanks!
  2. #2
  3. No Profile Picture
    Super Moderator
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Posts
    4,008
    Rep Power
    2790
    [PHP] | [Perl] | [Python] | [Java] != [JavaScript] | [XML] | [ANSI C] | [C++] | [LUA] | [MySQL] | [FirebirdSQL] | [PostgreSQL] | [HTML] | [XHTML] | [CSS]

    W3Fools - A W3Schools Intervention.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    9
    Rep Power
    0
    Originally Posted by lelales
    Hello,
    I need to check if the viewer is using an ipad or iphone, and if so, include a new css file.
    Can anyone help with this?
    thanks!
    Hi there,
    Although it is possible to use JavaScript to do device sniffing, wouldn't it be better to serve a user a different style sheet based on the width of their device? (for example, there are plenty of devices out there with similar screen dimensions to the iPad, yet which don't have iPad in their UA).

    To serve a different style sheet based on viewport width, you can use CSS media queries. Here's a good tutorial in case you want to find out more: http://webdesignerwall.com/tutorials...-media-queries
  6. #4
  7. No Profile Picture
    Super Moderator
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Posts
    4,008
    Rep Power
    2790
    I think it depends on the requirements, if resolution detection is needed then yes CSS would be a preferable option, although a fallback to Javascript is required for older browsers. For actual operating system detection you will require Javascript.
    [PHP] | [Perl] | [Python] | [Java] != [JavaScript] | [XML] | [ANSI C] | [C++] | [LUA] | [MySQL] | [FirebirdSQL] | [PostgreSQL] | [HTML] | [XHTML] | [CSS]

    W3Fools - A W3Schools Intervention.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    9
    Rep Power
    0
    Originally Posted by Winters
    I think it depends on the requirements, if resolution detection is needed then yes CSS would be a preferable option, although a fallback to Javascript is required for older browsers. For actual operating system detection you will require Javascript.
    Exactly that. I agree.
    However, if the OP does need to detect which OS is running, I would be interested to find out why (just personal curiosity).

IMN logo majestic logo threadwatch logo seochat tools logo