treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Load different header file if IPAD views website using PHP includes?

  • OK, here's my problem.

    I have a website with a flash animation in the header section. The header section (file) is loaded by using a standard PHP include. However, when viewed with an ipad the flash animation does not work. Is it possible to detect the ipad coming into the site and somehow load a different header file without the flash animation? (Don't really want to build an ipad version of the website for such a small issue.)

    Totally new to PHP - have only used very basic functions like includes etc.

    Thanks in advance for any help or guidance.

    John C
  • What are you looking to replace the Flash ani with.. video? image? slider?

    I know I have used Flash as a fallback, but I think you can do vice-verse too with HTML5 video embed... just change the order of the sources.



    <video id="video" width="300" height="200" poster="images/poster.jpg" controls>
    <source src="video/xxx.mp4" type="video/mp4">
    <source src="video/xxx.webm" type="video/webm">
    <source src="video/xxx.ogg" type="video/ogg">
    <embed></embed>
    </video>

  • David Walsh has an article on iPad detection, and shows how to do it in PHP quite simply. Once you've got whether iPad is supported into a boolean, you can just use an if/else statement to load the different headers.
  • Just pick a flash embed that shows alt content when flash is not supported. Works perfect for me.
  • Thanks for all of the responses. Will try your suggestions and report back

    John C