I'm a little confused as to how JavaScript is supposed to run on an AMP page.
I realized that my JavaScript must be executed in an iframe. Such an iframe should be placed on the page (75% at least from the top) and should be sent via https. This really works:
<amp-iframe
width=300
height=300
sandbox="allow-scripts allow-popups allow-popups-to-escape-sandbox"
layout="responsive"
frameborder="0"
src="https://localhost:8000/?p=myjs">
</amp-iframe>
On this page ( https://localhost:8000/?p=myjs) I can run js freely.
My problem is this:
How should I run my code against a main page document, including an iframe?
I tried to access window.parent.documentand blocked. (of course).
- , AMP , AMP, js ? js AMP? , ?