繁体   English   中英

如何从跨域iframe中访问父窗口的window.orientation?

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

我尝试了各种访问父窗口的方向变量的方法,但它似乎总是“未定义”或“空”。

这是我尝试访问父窗口方向的不同方法:

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

我还尝试了侦听“ orientationChanged”事件:

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

以上方法均无法检测iframe父对象的方向。

不幸的是,我需要使用iframe。 我正在设计一个将放置在跨域iframe中的移动页。 最好是,我希望能够从iframe中检测方向变化,而不是让客户端在页面上放置额外的javascript。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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