having fun with code

Tag Archives: portrait

Detecting iPhone’s orientation

Detecting the iPhone’s orientation on a website is very easy: the only thing needed is a little bit of Javascript to listen to the onorientationchange event: window.onorientationchange = function() {   if (window.orientation)     document.body.setAttribute('class', 'landscape');   else     document.body.setAttribute('class', 'portrait'); } window.onload = function() {   window.onorientationchange(); } The window.orientation variable can [...]

About the blog

This is a blog about development, focused mainly on Javascript but also other languages like python, shell scripts and more.

About the author

Eneko Alonso is a software engineer and UI developer with more than eight years of experience in software and web development. He lives in San Luis Obispo, California and works at LEVEL Studios.

Contact Info

Contact Info

PromoteJS

JavaScript JS Documentation