Posted By

luizlopes on 01/05/09


Tagged

javascript safari iphone vertical landscape orientation


Versions (?)

Who likes this?

12 people have marked this snippet as a favorite

kevcow
stavelin
fabianwizenfeld
umang_nine
mahalie
masondixon
ericschweichler
seanpowell
infinidad
guo3823538
diogoweb
yoitsben


iPhone Orientation Javascript


 / Published in: JavaScript
 

URL: http://nettuts.com/tutorials/tools-and-tips/learn-how-to-develop-for-the-iphone/

  1. <script type="text/javascript">
  2. function orient()
  3. {
  4. switch(window.orientation){
  5. case 0: document.getElementById("orient_css").href = "css/iphone_portrait.css";
  6. break;
  7.  
  8. case -90: document.getElementById("orient_css").href = "css/iphone_landscape.css";
  9. break;
  10.  
  11. case 90: document.getElementById("orient_css").href = "css/iphone_landscape.css";
  12. break;
  13.  
  14. }
  15.  
  16. window.onload = orient();
  17.  
  18.  
  19. </script>

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: monkey_monk on November 16, 2011

Nice, or simply : `window.onload = function(){

switch(window.orientation){
    case 0: orient_css.href = 'css/iphone_portait.css';
    break;

    case 90:
    case -90: document.getElementById('orient_css')`

You need to login to post a comment.