2

is there a way to capture an orientation change event in Windows phone 7 in the browser?

in Android and iOS there is the onOrientationchange() event - but in Windows mobile IE9 (Windows phone 7) it just don't work...

3 Answers 3

1

Unfortunately it doesn't look like you can. You could use some javascript to detect changes to the screen width though to emulate similar behaviour

1
1

if (navigator.userAgent.match(/Windows Phone/i)) { window.onresize = function (event) { ... } }

window.onorientationchange = function () { ... }

2
  • This does not work neither. On my Nokia Lumia 710 (WP7.5) there is no rotation. Page is only stretched to width when I rotate it to landscape. (T_T)
    – Radek Pech
    Feb 6, 2014 at 10:21
  • window.onresize = function (event) { window.alert(3);} Confirming event fires on my HTC HD7 when changing orientation. Also fires in HTC HD7 emulator.
    – John
    Feb 13, 2014 at 22:27
1

You could use a window.resize event as suggested by @Assaf, and detect the orientation with window.styleMedia.matchMedium("(orientation: landscape)");

matchMedium, is the non-standard Webkit precursor of HTML5 matchMedia supported in IE9.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.