Maybe this is a bad solution, but at least it works, and since I got control over the main page and the page displayed in the iframe, I donβt see that there should be any direct danger, Anyway, this is my solution :
I had the idea that the problem could be solved using javascript instead of CSS. But I still could not get the correct orientation even with javascript, so I assume that the problem actually stems from the fact that the page inside the iframe does not know anything about its parent environment. However, I found that you can call methods from the javascript main page if the methods are in a file called parent.js. This allows you to create a method that checks the orientation of the main page and calls it from a javascript iframe. This solution, of course, applies to any other similar problem. However, this requires that you gain access to both the code for the main page and the page loaded in the iframe.
Edit: As mentioned in the comments on muzzamo, this solution requires the code for the main page and the code for the iframe to be in the same domain. Sorry for the ambiguity! -From editing -
Code from parent.js:
function getDeviceOrientation() { var devOri = window.orientation; return devOri; }
Code from iframe.js:
function changeFontSize() { var parentOrientation = parent.getDeviceOrientation();
As already mentioned: I'm not sure if this is a GOOD solution, but in apartments this is a solution. Since I'm new to javascript, I will still be grateful for comments on my solution and / or other (better) solutions to the problem. But I hope this helps others with similar problems!
PS. Remember to also include the parent.js file in the head of the HTML file!
<script type="text/javascript" src="js/parent.js"></script>
source share