Detect Screen orientation
A client set me a challenge to determine if a Mobile device was portrait or landscape.
I thought this would be easy (20 minutes) but took me a couple of hours.
here is a test link http://www.test.elearninglaboratory.co.uk/Test/story.html
and I have attached the file, tested on iOS and Android (Nexus).
The problem I had was that I first tried window.orientation and then found out Samsung devices give different values compared to iOS and Nexus. So my next plan was screen.height and width but the iOS devices give the same value whatever the orientation.
Finally I did window.innerheight and width and then did some simple maths, a bit of a kludge and may not work on some devices. if someone has a simpler solution let me know (please).