Jesper
Jesper

Reputation: 91

device motion events not firing in tab opened from cross origin iframe chrome 62

Since Chrome 62 (on Android) I'm having issues with devicemotion events not being accessible inside cross-origin iframes.

To cope with this, without resorting to using postMessage to pass the devicemotion events along to the iframe, I open a new tab from the iframe using its own location. The new tab does not receive any device motion events however. Copy-pasting the url into a manually opened tab does result in devicemotion events being triggered.

I'm assuming that the new tab is sandboxed in some way but I've yet to find any way to get around this. How can I open a new tab that does not have this restriction? If that's not possible, is there any other way to get around the cross-doimain restrictions for the iframe?

I do not have access to the parent page.

Upvotes: 1

Views: 678

Answers (1)

Simon Lindahl
Simon Lindahl

Reputation: 19

I had the same issue but solved it by listening on top.window and not window.

top.window.addEventListener('devicemotion', myFunction, false);

Hope this helps.

Upvotes: 1

Related Questions