Create a page with the following javascript:
function say_width() {
alert(document.documentElement.clientWidth);
}
window.onload = say_width;
window.onresize = say_width;
1) The onload will always say 768 in both portrait and landscape. This is obviously not right and why doesn't it say 1024 when in landscape?
2) When you rotate the iPad it will fire onresize which will say the right width (either 320 or 576).
Giving the onload a tiny delay will avoid the issue:
window.onload = setTimeout(say_width, 15);
But wouldn't it be better to prevent any javascript from running until the iPhone emulation is applied?