Is there a way to manually adjust the screen properties of a dynamically generated iframe? I am looking to set orientation, width, and height in order to simulate a "mobile" view within that iframe.
I have prepared two separate fiddles for this:
The parent: https://jsfiddle.net/mooioom/69240vec/
The "device": https://jsfiddle.net/mooioom/19tsk4L8/
The parent opens an iframe pointing to the "device" with iPhone resolution dimensions 375x667.
The "device" contains a media query to match the iPhone resolution and should change the button color from green to yellow if detected. However, this doesn't happen, possibly due to the detected screen.width and screen.height dimensions.
So, my question is how can I set screen.width and screen.height of the "device" at creation time from the parent?
--- update ---
As Gezzasa mentioned, changing the media query from min-device-width to min-width makes it work. However, for a comprehensive solution, I still want to know how to make the iframe believe that it's being viewed on a mobile device. I've come across information suggesting that this involves modifying headers and user-agent because some responsive techniques target the user-agent to determine if it's a mobile device.
Putting that aside, the main question remains - how do you dynamically set the screen.width and screen.height (and orientation) for an iframe from a parent window?