DISABLE LANDSCAPE MODE ON MOBILE
Fri Aug 19 2022 11:04:11 GMT+0000 (Coordinated Universal Time)
Saved by
@mickeldav
#javascript
#jquery
//This will reload the hidden page when the user rotates the device.
jQuery(window).on("orientationchange",function(){
if(screen.availHeight < screen.availWidth){
//alert("chng");
jQuery( ".h-main-body" ).css( "display", "none" );
var newLine = "\r\n"
var msg = "Please Don't use Landscape!"
msg += newLine;
msg += "(Turn your phone)";
msg += newLine;
msg += "and wait a seconds,";
// msg += newLine;
// msg += "for the page to reload.";
alert(msg);
}
else{
jQuery( ".h-main-body" ).css( "display", "block" );
//location.reload();
}
});
content_copyCOPY
Comments
@mickeldav - Fri Aug 19 2022 11:05:26 GMT+0000 (Coordinated Universal Time)You can inform the user he has to change orientation and hide the screen. Then sense the orientation change and reload the page. The following code should be placed at the end of the template of your page or in the footer. This is to inform the user he should rotate the device, it hides the content You should confirm that the ".content" is the right selector on your page.