iphone orientation

sudhakararaog

Member
Aug 25, 2010
5
0
0
Visit site
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").setAttribute("class", contentType);
}

</script>
</head>


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

thanks
 

Trending Posts

Members online

Forum statistics

Threads
260,338
Messages
1,766,473
Members
441,237
Latest member
Tomwex73