Tuesday, 21 May 2013

Detect change of browser orientation with javascript

Today I needed to detect a change from landscape to portrait or vice versa on mobiles and tablets. So I did this:
window.addEventListener("orientationchange", function() {
  //do whatever you need to do
}, false);

No comments:

Post a Comment

Comments are moderated, so you'll have to wait a little bit before they appear!