Note that there are some explanatory texts on larger screens.

plurals
  1. POTelling the content of an iFrame the orientation
    primarykey
    data
    text
    <p>I currently have a web site with an iFrame that is designed for a tablet device (eg iPad). I am able to detect orientation in the parent to change the width and height of the iFrame itself, but I can't seem to get the iFrame page to detect the orientation of the device upon change.</p> <p>I know if I load the actual page from the iFrame itself in Safari Mobile without being in an iFrame, it detects changes and rotates according to the orientation at that time. If I load the page in landscape when its in the iFrame, it load the content in landscape, and visa-versa with being in portrait. It seems that it doesn't want to constantly detect orientation after it has loaded itself when in an iFrame, only upon initial load.</p> <p>Is there a way to tell the iFrame that the orientation has changed in some way? I have used this code, but without success:</p> <pre><code>window.addEventListener("orientationchange", function(){ var iframe = document.getElementById("youriframe").contentWindow; iframe.postMessage({ orientation: window.orientation }, 'http://the.domain.of.the.iframe.com'); }, false) </code></pre> <p>What makes it harder is that I can't edit the content of the iFrame as it isn't mine! The code below is what you're meant to inject into it!</p> <pre><code>window.addEventListener("message", function(e){ var newOrientationValue = e.data.orientation; alert(newOrientationValue); // &lt;--- DO your own logic HERE }, false) </code></pre> <p>Please help, I'be been racking my brain over this for days! Hope that all makes sense.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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