HTML
<h1>JavaScript Event: orientationchange</h1>
<p>
Silahkan putar device atau smartphone untuk melihat hasilnya:
</p>
<div id="demo"></div>
CSS
Type CSS code here...
x
JS
xxxxxxxxxx
9
document.getElementById("demo").innerHTML = screen.orientation.type; //Mengetahui orientasi awal
window.addEventListener("orientationchange", function() {
if ( window.orientation == 0 || window.orientation == 180) {
document.getElementById("demo").innerHTML = "MODE PORTRAIT";
} else {
document.getElementById("demo").innerHTML = "MODE LANDSCAPE";
}
}, false);
<!< ><> < ="https://raw.githack.com/albughisy7/BLOGGER/main/Jun_Kode/jQuery/jquery.min.js"></> <> *{:#1d1e22; border-color:#1d1e22; background: transparent;/*#fefefe*/ scrollbar-width:thin; scrollbar-color: #d8d8d8 transparent} input{border:1px solid; outline: none;} button{padding: 4px 8px} </style> </head><body> <h1>JavaScript Event: orientationchange</h1> >