I would like to use the API screen in Js with chrome.
if ( navigator.userAgent.match( /(android|iphone)/gi ) ) {
if ( 'orientation' in screen ) {
//console.log( '// API supported, yeah!' );
//console.log( 'new orientation is ', screen.orientation );
screen.lockOrientation( 'landscape' );
} else {
console.log( '// API not supported ' );
}
} else {
//alert('none');
}
my error js : caught TypeError: screen.lockOrientation is not a function
/* other */
if ( navigator.userAgent.match( /(android|iphone)/gi ) ) {
if ( 'orientation' in screen ) {
let locOrientation = screen.lockOrientation || screen.mozLockOrientation || screen.msLockOrientation;
locOrientation('landscape');
console.log( '// API supported, yeah!' , locOrientation);
console.log( 'new orientation is ', screen.orientation );
//screen.lockOrientation( 'landscape' );
} else {
console.log( '// API not supported ' );
}
} else {
//alert('none');
}
my error js : locOrientation is not a function
update : 20/04/2017 -> With Javascript, we can't lock orientation with the navigator.