有没有办法在浏览器中捕获 Windows phone 7 中的方向更改事件?
在 Android 和 iOS 中有 onOrientationchange() 事件 - 但在 Windows mobile IE9 (Windows phone 7) 中它只是不起作用......
有没有办法在浏览器中捕获 Windows phone 7 中的方向更改事件?
在 Android 和 iOS 中有 onOrientationchange() 事件 - 但在 Windows mobile IE9 (Windows phone 7) 中它只是不起作用......
不幸的是,它看起来不像你可以。您可以使用一些 javascript 来检测屏幕宽度的变化,但可以模拟类似的行为
if (navigator.userAgent.match(/Windows Phone/i)) { window.onresize = function (event) { ... } }
window.onorientationchange = 函数 () { ... }
您可以使用window.resize
@Assaf 建议的事件,并使用window.styleMedia.matchMedium("(orientation: landscape)");
matchMedium是IE9 支持的 HTML5 matchMedia 的非标准 Webkit 前身。