通过 JavaScript 检测 BlackBerry 9800 上的方向变化
我有一些 JavaScript (jQuery) 来捕获方向变化并在触发时创建 JS 警报:
$('document').ready(function(){
$('body').bind('orientationchange', function(e){
alert('orientation change triggered');
});
});
链接: http://jsbin .com/owebax/4
在 iPhone 上运行良好。它不适用于运行 OS6 的 BlackBerry 9800。
在进行一些谷歌搜索时,问题似乎是黑莓监视“窗口”而不是“主体”来改变方向。我将事件绑定到 window
:http://jsbin.com/owebax/5< /a>
但这在 Blackberry 上仍然不起作用(现在不再在 iPhone 上起作用)。
有人在 BlackBerry 9800 上触发了orientationchange JS 事件吗?
I have a bit of JavaScript (jQuery) to catch orientationchange and create a JS alert when triggered:
$('document').ready(function(){
$('body').bind('orientationchange', function(e){
alert('orientation change triggered');
});
});
link: http://jsbin.com/owebax/4
That works fine on an iPhone. It doesn't work on a BlackBerry 9800 running OS6.
In doing some googling, it appears that the issue might be that BlackBerry watches 'window' rather than 'body' for orientation change. I bound the event to window
instead: http://jsbin.com/owebax/5
But that still doesn't work on the Blackberry (and now no longer will work on the iPhone.)
Has anyone got orientationchange JS events to fire on the BlackBerry 9800?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我希望除了回答您的问题的“您的答案”之外,还有某种“令人尴尬的用户错误”标志。
所以事实证明我的问题是简单的语法混乱。我没有像这样尝试正确绑定到窗口:
我正在寻找一个名为“window”的标签“
doh!”
I wish that in addition to 'your answer' for answering your question there was a 'embarrassing user error' flag of some sorts.
So it turns out my issue was simple syntax snafu. Instead of trying to bind to window properly as such:
I was looking for a tag called 'window'
'doh!