(function () {
var supportorientation = (typeof window.orientation = = = ' Number ' &&
typeof Window.onorientationchange = = = ' object ');
var init = function () {
var htmlnode = Document.body.parentNode,
Orientation
var updateorientation = function () {
if (supportorientation) {
orientation = window.orientation;
Switch (orientation) {
Case 90:
CASE-90:
Orientation = ' landscape '; This is a horizontal screen.
Alert ("Horizontal screen");
Break
Default
Orientation = ' portrait ';//This is a vertical screen
Alert ("vertical screen");
Break
}
} else {
Orientation = (Window.innerwidth > Window.innerheight)? ' Landscape ': ' Portrait ';
}
Htmlnode.setattribute (' class ', orientation);
};
if (supportorientation) {
This event is called every time the rotation is rotated.
Window.addeventlistener (' Orientationchange ', updateorientation, false);
} else {
Monitoring Resize Events
Window.addeventlistener (' Resize ', updateorientation, false);
}
Updateorientation ();
};
Window.addeventlistener (' domcontentloaded ', init, false);
})();
Source: http://www.jb51.net/article/85438.htm
JS Detection mobile end of the screen