if you use iUI, it's already supported out-of-the-box !
See http://www.remi-grumeau.com/labs/iui/ --> Orientation Detection
In CSS:
body { normal for portrait mode }
body[orient="landscape"] { for landscape mode }
With that, you can do whatever you want tweaking in your CSS file
if not, this should do the trick
addEventListener("onorientationchange", function(event)
{
var orient = (window.innerWidth >
window.innerHeight)?'landscape':'portrait';
document.body.setAttribute("orient", orient);
}, false);
Remi Grumeau
(+33) 663 687 206
http://www.remi-grumeau.com
Le 20 févr. 2010 à 13:44, deset45 a écrit :
> Hello
>
> Im new to developing sites for the iphone.
>
> What i need is a way to change the layout or unhide if possible
> certain objects when the user changes from portrait to landscape etc
>
> For example, in portrait, it would be like this in portrait mode (I
> hope the layout is the same when it gets posted lol):
> ----------------------------------------------------------
> Main title .png
> ----------------------------------------------------------
>
> whatever >
> whatever2 >
> whatever3 >
>
> ----------------------------------------------------------
>
> but then when the user rotates to landscape:
> main banner is replaced, and a button is unhidden.
> ----------------------------------------------------------------------------------------------
> Larger alternatiive Main title .png (Button/anythingelse.png )
> ----------------------------------------------------------------------------------------------
> whatever
>>
> whatever2
>>
> whatever3
>>
> ----------------------------------------------------------------------------------------------
>
> Is it possiible to do this, or would it be much easier to just have
> some sort of code that detects if the user is in portrait mode and
> notifys them to rotate to landscape OR just force the viewing to come
> out landscape somehow.
>
> Can anyone help, and possible expand on their answer as Im more into
> the graphic side of websites rather than coding
>
> Thanks
>
> James
>
> --
> You received this message because you are subscribed to the Google Groups
> "iPhoneWebDev" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/iphonewebdev?hl=en.
>
--
You received this message because you are subscribed to the Google Groups
"iPhoneWebDev" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/iphonewebdev?hl=en.