5
A
回答
6
jQTouch檢查它像這樣:
orientation = Math.abs(window.orientation) == 90 ? 'landscape' : 'portrait';
http://github.com/senchalabs/jQTouch/blob/master/jqtouch/jqtouch.js
您還可以聽onorientationchange事件
參考先前的回答:Detect rotation of Android phone in the browser with JavaScript
4
你可以做一個簡單的檢查文件的寬度。
$(window).width();
您可以將其設置爲變量,然後根據iPad的原始分辨率檢查該變量:縱向768px x 1024px。
0
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Rotation Test</title>
<link type="text/css" href="css/style.css" rel="stylesheet"></style>
<script src="js/jquery-1.5.min.js" type="text/javascript"></script>
<script type="text/javascript">
window.addEventListener("resize", function() {
// Get screen size (inner/outerWidth, inner/outerHeight)
var height = $(window).height();
var width = $(window).width();
if(width>height) {
// Landscape
$("#mode").text("LANDSCAPE");
} else {
// Portrait
$("#mode").text("PORTRAIT");
}
}, false);
</script>
</head>
<body onorientationchange="updateOrientation();">
<div id="mode">LANDSCAPE</div>
</body>
</html>
0
你可以嘗試的解決方案,兼容所有眉毛呃。
以下是orientationchange
兼容性圖: 因此 ,我創作一個orientaionchange
填充工具,它是一個基於@media屬性來解決orientationchange實用library-- orientationchange-fix
window.addEventListener('orientationchange', function(){
if(window.neworientation.current === 'portrait|landscape'){
// do something……
} else {
// do something……
}
}, false);
,然後你可以檢索目前狀態的方向window.neworientation.current
和初始狀態的方向window.neworientation.init
。
相關問題
- 1. UISplitViewController出現在橫向模式縱向
- 2. iPad - 用於橫向和縱向模式的不同設計
- 3. iPad 1顯示縱向模式而不是橫向
- 4. pushViewController: - 當設備處於橫向模式時,如何以縱向模式顯示?
- 5. iOS - 當前處於橫向模式時如何強制縱向模式
- 6. 在橫向和縱向模式下啓動iPad應用程序
- 7. iPad的:問題在橫向和縱向
- 8. 方向縱向和橫向模式
- 9. 安卓相機處於橫向模式,但用於縱向模式
- 10. 設置縱向和橫向模式的飛濺圖像-IPad
- 11. iPad應用程序是否必須支持橫向和縱向?
- 12. Android:如何處理縱向反轉縱向和橫向反轉橫向事件
- 13. 如何在iOS 9上以橫向和縱向模式顯示iPad Launchscreen Storyboard?
- 14. IOS縱向和橫向模式
- 15. iPad從縱向轉爲橫向
- 16. iPad切斷橫向和縱向內容
- 17. 如何在橫向模式而不是縱向模式下捕獲avfoundation
- 18. iPad狀態欄方向鎖定(僅適用於橫向/縱向)
- 19. 如何確定設備是否使用CSS縱向或橫向模式
- 20. IPad應用程序首先進入縱向模式,然後在鎖定時處於橫向模式的屏幕解鎖後進入橫向模式
- 21. 當支持橫向模式時強制iPad應用以縱向模式啓動
- 22. 在iPad中鎖定橫向模式
- 23. 如果設備處於橫向模式,第一次應用處於縱向模式
- 24. 如何在橫向模式下加載UIViewController,如果它的父級處於縱向模式?
- 25. 如何以橫向適應縱向圖像在縱橫比保持縱橫比
- 26. 如何處理Android中的橫向或縱向模式啓動服務...?
- 27. 如何在代碼中處理Android縱向和橫向?
- 28. 方法getDrawingCache()返回null取決於縱向或橫向模式
- 29. Nexus 7 - 用於縱向和橫向模式的不同佈局
- 30. 而在橫向模式在iPad上
多數民衆贊成在一個好主意,我會嘗試它告訴你它是怎麼回事! – cat 2010-08-16 18:00:43
這到目前爲止工作很好,謝謝! – cat 2010-08-16 18:14:26
非常好!很高興我能幫上忙。 – MoDFoX 2010-08-16 18:15:16