On Nov 18, 4:46 pm, Remi Grumeau <[email protected]> wrote: > Do you see any better way to do so? > I would be pretty pleased to see a better solution for that
The point is that the test is ineffective. An alternative detection strategy is to set an onorientationchange listener, dispatch an orientationchange event and see if it is handled. However, assigning a value to window.onorientationchange (or using addEventListener or attachEvent) has no harmful consequences if the event is not supported. Given the absence of a useful test, and the lack of harmful consequences of assigning to an unsupported event, why test at all? Why not just attempt to set a listener, plan for a default behaviour if not supported and provide enhanced functionality if it is? To determine if particular functionality is needed, it is best to analyse the requirements and alternatives for achieving a successful outcome. If the intention is to provide a default layout for portrait and an additional layout for landscape, then to switch between the two when the device is rotated, then there is no need to test for support for the onorientationchange event. Simply assign a listener - if it's supported, the layout will change; if not, the user gets the default layout. The outcome is the same as can be expected from a feature testing strategy, but without the test. Given a choice, I'd pick the simpler strategy, which has the added benefit of less maintenance. In this case a dysfunctional test is not really an issue, it just means a few users who might have seen the landscape layout may not. But there is a good chance some will rely on it for more important functionality and be disappointed with the result. -- Rob -- 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.
