Block site seen by horizontal

Asked

Viewed 887 times

0

I wonder how I can block my site when viewed horizontally by mobile, when it can only be handled vertically.

It can be in Javascript or PHP however, this should only happen with mobile device.

OBS.: When I say block, I mean I will increment the script to appear a message that informs that the horizontal use is disabled.

  • Are you developing a mobile webapp? If not, impossible, because a common site does not have access to user settings, and there is no way you can set this, since your site is not installed on the user’s device. Search for identify Portrait and Landscape mode via browser.

  • There’s no way you can be sure if it’s a mobile device or not. Web technologies (mainly CSS and HTML) are fundamentally broken (usually made by committees of theorists who do not use it on a daily basis). So much so that they didn’t hit fundamental things, such as knowing the DPI of the screen, real amount of pixels, orientation of individual elements (evil and evil you can use @media + orientation, and it’s not 100% reliable). Unfortunately, you can’t innovate much for the web without restricting the public. Either make it simple for everyone, or make it complicated and only for those who have new machine and browser.

  • 2

    An alternative is to make it responsive, see an example of responsive website that works well on qq device: http://motherfuckingwebsite.com/

1 answer

4


Original response: Soen - forcing web-site to show in Landscape mode only

<style type="text/css">
    #warning-message { display: none; }
    @media only screen and (orientation:portrait){
        #wrapper { display:none; }
        #warning-message { display:block; }
    }
    @media only screen and (orientation:landscape){
        #warning-message { display:none; }
    }
</style>

<div id="wrapper">
    <!-- conteudo do seu site aqui -->
</div>
<div id="warning-message">
    this website is only viewable in landscape mode
</div>

that is, if the user tries to view your page that is not in landscape mode, you will see a message instead of the content.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.