Click here to Skip to main content
15,887,485 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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');
        }
      });
    });
Posted
Updated 18-Sep-16 22:04pm

1 solution

Did you Google for? For instance, a quick search gives: Android: Temporarily disable orientation changes in an Activity - Stack Overflow[^].
 
Share this answer
 
Comments
Maciej Los 19-Sep-16 4:12am    
5ed!
CPallini 19-Sep-16 4:21am    
Thank you!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900