![](/img/trans.png)
[英]jquery / javascript - listen for change in window orientation mode on mobile devices
[英]Javascript Alert on mobile devices based orientation
我正在嘗試提醒我的網站上的移動設備用戶以橫向模式使用他們的設備。 我有一個警告彈出,但似乎陷入無限循環。 用戶單擊確定后如何停止循環?
這是代碼:
window.ondeviceorientation = detectIPadOrientation;
function detectIPadOrientation ()
{
if ( orientation == 0 || orientation == 180 ){
alert ('Please use your iPad in landscape mode');
}
}
以下代碼將根據屏幕方向發送警報。 僅當屏幕處於橫向模式時才會發送警報。
window.onload = function() {
if ( window.orientation == 0 || window.orientation == 180 ) {
alert ('Please use your mobile device in landscape mode');
}
};
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.