Load Specific Stylesheets for iPhone depending on Orientation


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



Copy this code and paste it in your HTML
  1. <link rel="stylesheet" type="text/css" href="stylesheets/iphone_portrait.css" id="orient_css">
  2.  
  3. <script type="text/javascript" charset="utf-8">
  4. function orient()
  5. {
  6. switch(window.orientation){
  7. case 0: document.getElementbyId("orient_css").href = "stylesheets/iphone_portrait.css";
  8. break;
  9.  
  10. case -90: document.getElementbyId("orient_css").href = "stylesheets/iphone_landscape.css";
  11. break;
  12.  
  13. case 90: document.getElementbyId("orient_css").href = "stylesheets/iphone_landscape.css";
  14. break;
  15. }
  16. }
  17. window.onload = orient();
  18.  
  19. <body onorientationchange="orient();">

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.