Posted By

conspirator on 10/02/08


Tagged

css javascript textmate iphone portrait landscape orientation CSS-Tricks


Versions (?)

Who likes this?

5 people have marked this snippet as a favorite

jamesming
SpinZ
trey
umang_nine
VeXHarbinger


Load Specific Stylesheets for iPhone depending on Orientation


 / Published in: Other
 

  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. </script>
  19.  
  20. <body onorientationchange="orient();">

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: mikersson on April 22, 2011

And what is the problem by adding just a normal iPhone css?? users will have problems to lead the page? I wonder if this is just an extra detail for be sure that will not be any error.

You need to login to post a comment.