在加载时评估orientationEvent?
我正在开发一个网络应用程序,它要求我根据orientationEvent 更改内容。到目前为止,它运行良好,当我改变方向时,它会更改和设置内容。但是,我需要orientationEvent 也能在onLoad 上触发。这可能吗?
$(document).ready(function(){
var onChanged = function() { //TODO: Need to learn a way to fire it at load time
if(window.orientation == 90 || window.orientation == -90){
$('#nav').html('<b> : LANDSCAPE : </b>');
}else{
$('#nav').html('<b> : PORTRAIT : </b>');
}
event.stopPropagation();
}
$(window).bind(orientationEvent, onChanged);
});
I'm working on a web app and it requires me to alter content based on the orientationEvent. It's working well so far, changing and setting content as I change orientation. However, I need the orientationEvent to also fire at onLoad. Is this possible?
$(document).ready(function(){
var onChanged = function() { //TODO: Need to learn a way to fire it at load time
if(window.orientation == 90 || window.orientation == -90){
$('#nav').html('<b> : LANDSCAPE : </b>');
}else{
$('#nav').html('<b> : PORTRAIT : </b>');
}
event.stopPropagation();
}
$(window).bind(orientationEvent, onChanged);
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)