/ Published in: JavaScript
URL: http://net.tutsplus.com/tutorials/tools-and-tips/learn-how-to-develop-for-the-iphone/
Switches stylesheets depending on orientation of iPhone (landscape vs.portrait).
Expand |
Embed | Plain Text
Link to initial stylesheet, with ID: <link rel="stylesheet" type="text/css" media="screen" href="<?php bloginfo('stylesheet_directory'); ?>/css/iphone-portrait.css" id="orient_css"> Script in <head>: <script type="text/javascript"> function orient() { switch(window.orientation){ case 0: document.getElementById("orient_css").href = "<?php bloginfo('stylesheet_directory'); ?>/css/iphone-portrait.css"; break; case -90: document.getElementById("orient_css").href = "<?php bloginfo('stylesheet_directory'); ?>/css/iphone-landscape.css"; break; case 90: document.getElementById("orient_css").href = "<?php bloginfo('stylesheet_directory'); ?>/css/iphone-landscape.css"; break; } } window.onload = orient(); </script> Then init from the <body> tag: <body class="iphone" onorientationchange="orient();">
You need to login to post a comment.
