有没有办法阻止手机中的横向视图或通过jquery或任何东西阻止平板电脑中的纵向视图? [英] Is there any way to prevent landscape view in phones or prevent portrait view in tablets by jquery or anything?
本文介绍了有没有办法阻止手机中的横向视图或通过jquery或任何东西阻止平板电脑中的纵向视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Jquery开发一个ASP.NET MVC应用程序。
我要求防止手机中的横向视图或阻止平板电脑中的纵向视图。
我搜索了各种各样的东西,但我无法找到任何参考。那么,有什么东西可以帮助我吗?
我尝试过:
我试过以下但没有工作......
I am developing an ASP.NET MVC application with Jquery.
I have a requirement to Prevent landscape view in phones or prevent portrait view in Tablets.
I have searched various things but I am unable to find out any reference. So, is there anything exists which can help me here?
What I have tried:
I have tried below but not working...
$(document).on("pagecreate",function(event){
$(window).on("orientationchange",function(){
if(window.orientation == 0)
{
alert("potrait");
}
else
{
alert("landscape");
window.screen.lockOrientation('landscape');
}
});
});
推荐答案
(document).on(pagecreate,function(event) {
(document).on("pagecreate",function(event){
(窗口).on(orientationchange,function(){
if(window.orientation == 0)
{
alert( potrait);
}
其他
{
alert(landscape);
window.screen.lockOrientation('landscape');
}
});
});
(window).on("orientationchange",function(){ if(window.orientation == 0) { alert("potrait"); } else { alert("landscape"); window.screen.lockOrientation('landscape'); } }); });
你 Google 了吗?例如,快速搜索给出: Android:暂时禁用方向更改活动 - 堆栈溢出 [ ^ ]。
Did you Google for? For instance, a quick search gives: Android: Temporarily disable orientation changes in an Activity - Stack Overflow[^].
这篇关于有没有办法阻止手机中的横向视图或通过jquery或任何东西阻止平板电脑中的纵向视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文