Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You can be <a href="http://developer.apple.com/safari/library/documentation/AppleApplications/Reference/SafariWebContent/HandlingEvents/HandlingEvents.html#//apple_ref/doc/uid/TP40006511-SW24" rel="nofollow noreferrer">notified when the orientation changes</a>, by using the <code>onorientationchange</code> property of the <code>body</code> tag.</p> <p>You can use code similar to <a href="https://stackoverflow.com/questions/1879386/how-to-control-screen-orientation-for-iphone-in-web-app/1879456#1879456">this answer's</a>, which monitors the orientation change and then flips the content so that it appears to the user as always facing one direction.</p> <p>Note that while you can <a href="http://developer.apple.com/safari/library/documentation/AppleApplications/Reference/SafariWebContent/HandlingEvents/HandlingEvents.html#//apple_ref/doc/uid/TP40006511-SW24" rel="nofollow noreferrer">prevent default behavior</a> on some events using code like this:</p> <pre><code>function touchMove(event) { // Prevent scrolling on this element event.preventDefault(); ... } </code></pre> <p>It doesn't mention anything about preventing orientation changes:</p> <blockquote> <p>iPhone OS Note: The preventDefault method applies to <strong>multi-touch</strong> and <strong>gesture</strong> input in iPhone OS 2.0 and later.<br> <em>[emphasis added]</em></p> </blockquote> <p>Additionally, the <a href="http://developer.apple.com/safari/library/documentation/DataManagement/Reference/DOMWindowAdditionsReference/DOMWindowAdditions/DOMWindowAdditions.html#//apple_ref/javascript/instp/DOMWindow/orientation" rel="nofollow noreferrer">orientation</a> property is readonly.</p> <p>And so, you must write your own code like the one I linked to above.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload