아는 것이 좋은 것이다.

[JavaScript] 모바일 회전 감지 스크립트 본문

JavaScript

[JavaScript] 모바일 회전 감지 스크립트

start0 2014. 5. 27. 17:37
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.css" />
    <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
    <script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"></script>

    <script type="text/javascript">
        $("document").ready(function() {
            $(window).trigger("orientationchange");
        });
 
        $(window).bind("orientationchange", function(e) {
            var orientation = window.orientation;
 
            if (orientation == 90 || orientation == -90) {
                alert("landscape");
            } else {
                alert("portrait");
} }); </script>


Comments