Detecting orientation change on mobile devices

This code will add an action listener to your window. A value of 0 means portrait view, -90 means a the device is landscape rotated to the right, and 90 means the device is landscape rotated to the left.

window.addEventListener("orientationchange", function() {
	// Announce the new orientation number
}, false);


Share this snippet


Leave a Reply

Your email address will not be published. Required fields are marked *

Please respect the following rules: No advertising, no spam, no keyword in name field. Thank you!