简体   繁体   中英

How can I access window.orientation of parent window from inside a cross-domain iframe?

I have tried various ways of accessing a parent window's orientation variable, but it always seems to be either "undefined" or "null".

Here are the different ways I've tried accessing the parent window's orientation:

parent.window.orientation
window.parent.orientation
window.opener.orientation
parent.document.orientation (shouldn't work, but I tried anyway)
parent.orientation

I've also tried listening for the "orientationChanged" event:

parent.document.addEventListener('orientationChanged',function() {
    alert('orientation changed');
    });

None of the above methods are able to detect the orientation of an iframe parent.

Unfortunately, I am required to use iframes. I am designing a mobile page that will be placed into a cross-domain iframe. Preferably, I want to be able to detect an orientation change from within the iframe instead of having the client put extra javascript on their page.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM