0

Is there anyway to detect when the orientation of the user's screen changes?

I'd like to fire some javascript functions when this happens to update various bits of content.

For example, I have a set of divs displayed as an accordion. Each div displays +/- icons to show / hide its content.

When the page loads in landscape, the content in each div is displayed by default, however when it loads in portrait the content is hidden.

I need to reset the +/- icons when the orientation of the screen changes.

Are there any events I can hook into to achieve this?

Any advice appreciated.

Thanks.

Dan
  • 6,265
  • 8
  • 40
  • 56
  • Zurb has the following classes which might be useful show-for-landscape and show-for-portrait. See the documentation here: http://foundation.zurb.com/docs/components/visibility.html – Vahi Oct 22 '14 at 15:46
  • 2
    Using Javascript : http://stackoverflow.com/questions/4917664/detect-viewport-orientation-if-orientation-is-portrait-display-alert-message-ad Using Jquery :http://stackoverflow.com/questions/15980680/can-i-determine-if-a-device-is-in-portrait-or-landscape-mode-using-jquery – Vahi Oct 22 '14 at 15:50

0 Answers0