1. sudhakararaog's Avatar
    i am using the following code i need to detect the chnage in orientation and in css i am simply chaging the background colors when in portrait and landscape mode however this code is not detecting the orientation change

    1.

    <head>
    <link rel="StyleSheet" href="iphone.css" type="text/css" media="screen" id="orient_css" />

    <script type="text/javascript">
    function orient()
    {
    switch(window.orientation)
    {
    case 0: document.getElementById("orient_css").href = "iphone_portrait.css";
    break;

    case -90: document.getElementById("orient_css").href = "iphone_landscape.css";
    break;

    case 90: document.getElementById("orient_css").href = "iphone_landscape.css";
    break;
    }
    }
    window.onload = orient();

    </script>
    </head>

    <body onorientationchange="orient();">



    2.
    <head>
    <script type="text/javascript">

    window.onload = function initialLoad() {
    updateOrientation();
    }

    function updateOrientation(){
    var contentType = "show_";
    switch(window.orientation){
    case 0:
    contentType += "normal";
    break;

    case -90:
    contentType += "right";
    break;

    case 90:
    contentType += "left";
    break;

    case 180:
    contentType += "flipped";
    break;
    }
    document.getElementById("page_wrapper").setAttribu te("class", contentType);
    }

    </script>
    </head>


    please advice how to change the code to detect the iphone orientation

    thanks
    11-15-2010 05:57 PM
LINK TO POST COPIED TO CLIPBOARD