Is there any way to keep mobile website in landscape mode on mobile devices?
Can we do it using any JavaScript code?
Is there any way to keep mobile website in landscape mode on mobile devices?
Can we do it using any JavaScript code?
Restricting user may spoil the user exp,if you are sure that it wouldnt ruin the experience go ahead with this code--->
//this function will rotate you screen(cross browser!!!)
function rotate(el, degs) {
iedegs = degs/90;
if (iedegs < 0) iedegs += 4);
transform = 'rotate('+degs+'deg)';
iefilter = 'progid:DXImageTransform.Microsoft.BasicImage(rotation='+iedegs+')';
styles = {
transform: transform,
'-webkit-transform': transform,
'-moz-transform': transform,
'-o-transform': transform,
filter: iefilter,
'-ms-filter': iefilter
};
$(el).css(styles);
}
//this will check your orientation and then take action as you desrired!!!
$(window).bind('orientationchange resize', function(event){
if(event.orientation) {
if (event.orientation == 'landscape') {
if (window.rotation == 90) {
rotate(this, -90);
} else {
rotate(this, 90);
}
}
});