<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Orientation</title>
<meta name="viewport" content="width=device-width; initial-
scale=1.0; minimum-scale=1.0; maximum-scale=1.0; user-scalable=0;">
<script type="text/javascript">
window.onload= window.onunload= window.onorientationchange=
window.onresize= function ()
{
var w= window,
x= function (p) { return document.getElementById(p) };
x('target').innerHTML= w.orientation+", "+w.innerWidth+",
"+w.innerHeight+'<br/>'+Date();
}
</script>
</head>
<body>
<h2>Tracking Orientation</h2>
State: <span id="target"></span><br/>
<a href="static.html">link out</a><br/>
</body>
</html>
Obviously there's some bug because
1.- these events are not always being posted at the right time (remove
window.onunload and you'll see what I mean)
and,
2.- w.innerWidth when in portrait sometimes becomes 240 (?),
But written in this way at least w.orientation seems to be reported
correctly, all of the times.
--Jorge.
El 30/05/2008, a las 19:58, Sean Gilligan escribió:
> p.s. Occasionally, clicking "Read window.orientation" seems to
> trigger a resize event that otherwise would not have happened.
>
> -- Sean
>
>
> Sean Gilligan wrote:
>>
>> window.orientation always seems to have the correct value if
>> polled. But I don't know of a reliable strategy for using event
>> handlers to track the state of window.orientation.
>>
>> I have created a test program and put it in the iui samples
>> directory on Google Code:
>> http://iui.googlecode.com/svn/trunk/samples/orient.html
>>
>> 1) Load this page on your iPhone
>> 2) Touch the "link out" link
>> 3) Wait for the "Static" page to load
>> 4) Change the orientation on your phone
>> 4) Click the back button on your iPhone
>> 5) Notice that three indicators of orientation read "unknown"
>> (The "Load Events" indicator should have original orientation
>> listed)
>> 6) Click the "Read window.orientation" javascript link
>> 7) You'll notice that "Manual State" now correctly indicates
>> orientation
>>
>> The source for this page is really simple (based upon Apple's
>> sample code)
>>
>> So, does anyone have an idea for how to track all orientation
>> changes without using setInterval()?
>>
>> -- Sean
>>
>>
>> Peter Blazejewicz wrote:
>>>
>>> hi,
>>>
>>> "window.orientation" {0, 90, -90}
>>> does it work in use cases raised in first post?
>>>
>>> regards,
>>> Peter
>>>
>>> On May 30, 10:18 am, Chrilith <[EMAIL PROTECTED]> wrote:
>>>
>>>> Could you be more specific?
>>>>
>>>> On May 30, 12:16 am, Peter Blazejewicz
>>>> <[EMAIL PROTECTED]>
>>>> wrote:
>>>>
>>>>
>>>>> hi guys,
>>>>>
>>>>> except of Window event there is a window orientation property if
>>>>> my
>>>>> memory serves me correctly, is there?
>>>>>
>>>>> regards,
>>>>> Peter
>>>>>
>>>>> On May 28, 10:06 am, Chrilith <[EMAIL PROTECTED]> wrote:
>>>>>
>>>>>> No, this seems to be more a limitation (bug?) of Safari
>>>>>>
>>>>>> On May 27, 10:35 pm, Sean Gilligan <[EMAIL PROTECTED]> wrote:
>>>>>>
>>>>>>> Using onload and onorientation handlers I can track the
>>>>>>> orientation
>>>>>>> state of the page without needing to use setInterval(), except
>>>>>>> for (at
>>>>>>> least) the following case:
>>>>>>>
>>>>>>> 1. Page is loaded in portrait mode
>>>>>>> 2. User follows a link to another page
>>>>>>> 3. User rotates the iPhone while viewing the other page
>>>>>>> 4. User uses the back button in Safari
>>>>>>>
>>>>>>> When the page is redrawn, neither the onload or onorientation
>>>>>>> handlers
>>>>>>> will fire.
>>>>>>>
>>>>>>> Has anyone solved this problem without using setInterval to
>>>>>>> poll?
>>>>>>>
>>>>>>> Thanks,
>>>>>>>
>>>>>>> Sean
>>>>>>>
>>>
>>>
>>>
>>
>>
>
> >
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---