I have been messing with some of this recently and i have used two different approaches when programming an iPhone / iPod site.
The first way I came across when looking for orientation changes so you can see whether the phone is portrait or landscape, this is a very static way but simple and clever:
In CSS :
#content_right,
#content_normal{
display:none;
}
In JS File:
function updateOrientation(){
var contentType = "show_";
switch(window.orientation){
case 0:
contentType += "normal";
break;
case -90:
contentType += "right";
break; document.getElementById("page_wrapper").setAttribute("class",contentType);
}
In PHP/HTML (Import your JS file first then in body tag):
<body onorientationchange="updateOrientation();">
This basically chooses a different pre set CSS block to run depending on the result given back from the JS file.
Also the more dynamic way which I preferred was a very simple addition to a script tag or your JS file:
document.getelementbyid(id).style.backgroundColor = '#ffffff';
This works for most browsers but for IE it's best to take away it's ammunition with something tighter:
var yourID = document.getelementbyid(id);
if(yourID.currentstyle) {
yourID.style.backgroundColor = "#ffffff"; // for ie :@
} else {
yourID.style.setProperty("background-color", "#ffffff"); // everything else :)
}
Or you can use getElementByClass()
and change a range of items.
Hope this helps!
Ash.