Javascript iOS / Desktop detection


/ Published in: HTML
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <div id="ios_content" style="display:none;">
  2. <img src="assets/2012images/homepage-12.jpg" alt="You are now in Richard Petty's Garage!">
  3. </div>
  4. <div id="desktop_content" style="display:none;">
  5. <object width="741" height="455" data="assets/flash/animation.swf" type="application/x-shockwave-flash">
  6. <param name="src" value="assets/flash/animation.swf" />
  7. </object>
  8. </div>
  9. <script type="text/javascript">
  10. var isiPad = navigator.userAgent.match(/iPad/i) != null;
  11. var isiPhone = navigator.userAgent.match(/iPhone/i) != null;
  12. var isiPod = navigator.userAgent.match(/iPod/i) != null;
  13. var content = "";
  14. if(isiPad==true || isiPhone==true || isiPod==true)
  15. document.getElementById('ios_content').style.display="block";
  16. else
  17. document.getElementById('desktop_content').style.display="block";

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.