Lock orientation
- Started
- Last post
- 4 Responses
- RobertLarsen
I'm looking for some css or javascript code that will lock the iOS screen orientation to portrait in a mobile website. I've Googled and did not find a working solution. Is it even possible?
- detritus0
I sincerely hope that's not possible.
- GeorgesIV0
I don,t think its possible but you can detect orientation,
so maybe use a light box to ask the user to turn his tablet or lock it
http://mislav.uniqpath.com/2010/…
http://www.williammalone.com/art…
- utopian0
iPhone Viewport Orientation
The iPhone supports both landscape and portrait views. You can specify CSS based on viewport orientation which you determine via javascript and update the orient attribute of the body element. Target the browser with body[orient="landscape"] or body[orient="portrait"]
iPhone ViewPort Orientation JavaScript
The following javascript snippet detects and sets the iPhone’s viewport orientation by evaluating the innerWidth property of the window object and setting the orient attribute of the body element at regular intervals:
var updateLayout = function() {
if (window.innerWidth != currentWidth) {
currentWidth = window.innerWidth;
var orient = (currentWidth == 320) ? "profile" : "landscape";
document.body.setAttribute("orie... orient);
window.scrollTo(0, 1);
}
};iPhone.DomLoad(updateLayout);
setInterval(updateLayout, 500);