检测iframe中的方向更改

时间:2014-05-22 11:32:46

标签: javascript jquery html iframe

我有一个Html页面,在该页面内有一个iframe。在Iframe src页面中,我编写了代码来检测方向并执行某些操作。 当我在浏览器中单独启动iframe URL时会检测到方向更改,但是当我使用iframe时,未检测到方向更改。我是否需要使用任何插件?

1 个答案:

答案 0 :(得分:2)

这仅适用于您的iframe位于同一个域中,并且如果它们触发了' orientationchange'事件

$(document).add(parent.document).on('orientationchange',function() {
 // your logic
});