How does the mobile end force the page to landscape?

now I am working on a game landing page with a 1200-high picture in the background, which is not high enough to fill the screen when placed on the phone. I hope to be able to force the horizontal screen when the phone is turned on.

method I found:

/ / determine screen orientation
if (window.orientation==90 | | window.orientation==-90) {

alert("")

}

/ / listen for screen orientation
window.onorientationchange = function () {

switch(window.orientation){ 
    case -90: 
    case 90: 
        alert(":" + window.orientation);
    case 0: 
    case 180: 
         alert(":" + window.orientation);
    break; 
} 

}

but after testing, I found that window.orientation has been abandoned. Is there any other way to do it?

Mar.07,2021

in the rotation event, the width-height pixel value is compared, and the width-to-height ratio is the horizontal screen

.
Menu