iphone orientation

sudhakararaog

Standard Member
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" />

******** 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>
******** 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").setAttribute("class", contentType);
}

</script>
</head>


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

thanks
 

The latest video from AVForums

Star Wars Andor, Woman King, more Star Trek 4K, Rings of Power & the latest TV, movies & 4K releases
Subscribe to our YouTube channel
Support AVForums with Patreon

Top Bottom