I am faced with a situation where I have an iframe and two different sets of CSS codes - one for landscape orientation and one for portrait orientation. However, these are not specifically for the device's orientation but rather for the content loaded within the iframe, such as games designed in either landscape or portrait mode.
Both sets of CSS work well individually when enabled, but I would like to have a single button that can trigger the loading of the iframe with the corresponding CSS based on a data attribute. For example:
<a href="mygamelink" target="iframe" data="portrait">click me to play</a>
Upon clicking the above link, the iframe should load/change its class accordingly to apply the portrait-specific CSS.
<a href="mygamelink" target="iframe" data="landscape">click me to play</a>
Similarly, clicking this link should load/change the iframe's class to apply the landscape-specific CSS.
<iframe class="portrait/landscape" name="iframe"></a>
I am aware that achieving this functionality is possible with jQuery. Any ideas on how to implement it?