0

I am trying to test mobile devices in both landscape and portrait mode using javascript. So i need to check which orientation is working now and do some process and same process want to do in another orientation also.

I want to do some process in landscape and portrait mode

Itam
  • 1

1 Answers1

0
let portrait = window.matchMedia("(orientation: portrait)");

portrait.addEventListener("change", function(e) {
    if(e.matches) {
        // Portrait mode
    } else {
        // Landscape
    }
})