Add below code in your JavaScript:
window.addEventListener("orientationchange", function(event) { var orientation = (window.screen.orientation || {}).type || window.screen.mozOrientation || window.screen.msOrientation; if (["landscape-primary","landscape-secondary"].indexOf(orientation) !== -1) { becomeFullscreen(); } else if (orientation === undefined) { console.log("The orientation API isn't supported in this browser :("); }});