检测iframe中的方向更改

Tus*_*kur 5 html javascript iframe jquery

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

Mat*_*ius 2

仅当您的 iframe 位于同一域中并且它们触发“orientationchange”事件时,此功能才有效。

$(document).add(parent.document).on('orientationchange',function() {
 // your logic
});
Run Code Online (Sandbox Code Playgroud)