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...

gmadar
  • 1,884
  • 3
  • 19
  • 22

3 Answers3

1

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

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

Assaf
  • 11
  • 1
  • 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 06 '14 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 '14 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.

hexalys
  • 5,177
  • 3
  • 31
  • 56
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

Jordan Wallwork
  • 3,116
  • 2
  • 24
  • 49
  • thanks! I also found this : http://stackoverflow.com/questions/7280579/detecting-orientation-of-windows-phone it basically says what you wrote... – gmadar Dec 07 '11 at 15:08